Islam Isgandarov
Islam Isgandarov

Reputation: 11

LDAP query does not work when device is domain member

This php code gives error when my device uses it as domain member.

$ldap = @ldap_connect(ldaphost,ldapport);

ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);

if(@ldap_bind($ldap,login,password)){

$result = ldap_search($this->lcon,'DC=XXXXXXX,DC=CRP','(&(memberOf=CN=XXXXXX,OU=XXXXXX,DC=XXXXX,DC=CRP)(sAMAccountName='.login.'))')  ;   
    }  

Upvotes: 0

Views: 118

Answers (2)

Islam Isgandarov
Islam Isgandarov

Reputation: 11

For fixing it I used LDAP.php from here

Upvotes: 0

heiglandreas
heiglandreas

Reputation: 3861

Try this:

$ldap = @ldap_connect(ldaphost,ldapport);
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
if(@ldap_bind($ldap,login,password)){
    $result = ldap_search($this->lcon,'DC=XXXXXXX,DC=CRP','(&(memberOf=CN=XXXXXX,OU=XXXXXX,DC=XXXXX,DC=CRP)(sAMAccountName='.login.'))');   
}  

I just changed the surrounding " to ' and removed the inner " in the ldap_search-command.

Upvotes: 0

Related Questions