phpactive-directoryldap-querydistinguishedname

What's my Active Directory Distinguished Name? What's my LDAP TREE?


I'm trying to make auth calls connecting from php to an Active Directory server auth looks fine but I don't know what to put as ldap_search parameters.

dump of ldap_connect:

resource(4) of type (ldap link)

dump of ldap_bind:

bool(true)

dump of ldap_search:

resource(5) of type (ldap result)

dump of ldap_get_entries:

array(1) {
  ["count"]=>
  int(0)
}

I tried an endless number of permutation of this kind of parameters:

$ldap_dn = "CN=Users,DC=ad,DC=domain";

$ldap_filter = "(objectClass=*)";

but I'm not sure what exactly to put as DC= value in my specific case or O= or OU= or CN= or whatever, any help will be appreciated.


Solution

  • The base distinguished name is the base distinguished name you'd like to perform operations on. An example base DN would be DC=corp,DC=acme,DC=org.

    You can learn it from your active directory server manager.

    I also recommend you to use adLDAP Package

    It is a PHP class that provides LDAP authentication and integration with Active Directory.

    If one dc is not defined, then the package will try to find it automatically by querying your server. It's recommended to include it to limit queries executed per request. It has some custom functions that use PHP's defualt ones. Hence, using the package may make your work easier.