EyesOfNetworkCommunity / eonweb

EyesOfNetwork web interface
8 stars 12 forks source link

Unable to add ldap user and workaround #113

Open jsouville opened 2 years ago

jsouville commented 2 years ago

Hello,

I'm managing eyesofnetwork solution on production (~1000 hosts, 4 nagios backend). For several months i'm unable to add a new ldap user. Our system uses a openldap directory.

The problem appears after 5.3-11 eonweb update.

LDAP configuration and filters are OK (tested with ldapsearch).

On the auth setting page, when I use the update button, all is OK, entries are correctly found :

eoonauthupdate

But when using add user page, i can't found recent ldap users. Only old ones.

In eonweb database, recent ldap users are not present in ldap_users_extended table. I can also see that "user" column is empty for all row. I think this is not new and was not a problem for our usage before but I may be wrong here.

After investigation, I found on authentification setting page ( file module/admin_auth/index.php ) , a variable initialisation which explain this behaviour.

On line 175 , file module/admin_auth/index.php :

$username=$info[$i]["name"][0];

Our ldap user entries doesn't have a attribute "name". So this variable is NULL on my case

This variable is then used for sql query below. I have activate query log on mariadb. Query generated for insertion is :

INSERT INTO ldap_users_extended VALUES( 'uid=xxxxxxx,ou=users,ou=xxxxx,o=xxxxxxxxxx,c=xxxxxx', 'xxxxxxx', NULL, 1)

And causes the error :

Error Code: 1048. Column 'user' cannot be null

Workarounds I use :

  1. Change on line 175 , file module/admin_auth/index.php :

$username=$info[$i][$ldap_rdn]][0];

login and user name are the same for us, this is sufficient for our usage but may not be adequate for everbody. With this modification i have now the user column correctly set.

  1. Add double quotes when using $username variable , lines 179 and 188

Exemple for lines 185-189

  $datas2 = array(
          $dn,
          $info[$i][$ldap_rdn]["0"],
          "$username"
  );
liberodark commented 2 years ago

Hi;

This issue is very painful thank for your workaround.

Best Regards