sivann / itdb

IT Items Database
http://www.sivann.gr/software/itdb/
GNU General Public License v3.0
153 stars 104 forks source link

Active directory settings #44

Closed abazeed closed 8 years ago

abazeed commented 8 years ago

I tried to connect ITDB to the active directory, but I've failed to login using an active directory user. Is it working or not? and if someone succeeded to connect to AD, could he advise me please?

abazeed commented 8 years ago

I'm getting this error:

uid=jafar,dc=Dak,dc=local
Warning: ldap_bind(): Unable to bind to server:
Invalid credentials in E:\www\htdocs\it\functions.php on line 237
Entropede commented 8 years ago

Several reasons may be the cause . Looking for that error ("Unable to bind to server") on this page: http://php.net/manual/fr/function.ldap-bind.php .

We use LDAP in Itdb and everything is right on our side.

boki69 commented 8 years ago

Anonymous bind is not allowed to AD and you have to use some properties to set.

This is my code in function.php, that is allowed to bind and connect with user in AD:

$ds=ldap_connect($ldap_server);  // must be a valid LDAP server!
//echo "connect result is " . $ds . "<br />\n";
if($ds){
    //$dn="uid=".$username.",".$ldap_dn;
    $dn=$username."@example.com";  //<--- Change domain name!!!

    ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
    ldap_set_option($ds, LDAP_OPT_REFERRALS,0);
    $r=ldap_bind($ds,$dn, $passwd);
    //$r=true;
    if(!$r){
        $gen_errorstr="ldap_bind: ".ldap_error($ds);
        $gen_error=100;
        ldap_close($ds);
        return FALSE;
    }
    return $ds;    //echo "connect result is " . $ds . "<br />\n";
Entropede commented 8 years ago

What is the diff with the original codes, this whole codes ?

sivann commented 8 years ago

Sorry, cannot provide windows support, especially AD, as I don't have access to one. LDAP is only tested with openLDAP.