2023年6月21日发(作者:)
phpldap查找,php–LDAP过滤器–查找特定OU的所有⽤户我在使⽤LDAP搜索过滤器时遇到问题.我需要检索的是特定LDAP组的所有⽤户,即OU = Staff,OU = Users,OU = Accounts,DC =test,DC = local我的搜索是:(&(objectCategory=user)(OU=Staff,OU=Users,OU=Accounts,DC=test,DC=local))⽬前它没有返回任何结果.我错过了什么?解决⽅法:你必须做两件事>设置搜索的基础OU = Staff,OU = Users,OU = Accounts,DC = test,DC = local>使⽤objectClass搜索对象.使⽤PHP,搜索将如下所⽰(基于this PHP sample)://You must bind, first// using ldap bind$ldaprdn = 'yourdomainnic_hubbard'; // ldap rdn or dn$ldappass = 'password'; // associated password// connect to ldap server$ldapconn = ldap_connect("")or die("Could not connect to LDAP server.");if ($ldapconn) {// binding to ldap server$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);$dn = "OU=Staff,OU=Users,OU=Accounts,DC=test,DC=local";$filter="(objectClass=user)";$justthese = array("cn", "sn", "givenname", "mail");$sr=ldap_search($ldapconn, $dn, $filter, $justthese);$info = ldap_get_entries($ldapconn, $sr);echo $info["count"]." entries returnedn";}>您可以使⽤此命令在命令⾏上进⾏测试(确切的选项有所不同,这适⽤于最近的openldap的客户端⼯具):ldapsearch -H ldap:// -x -D "yourdomainnic_hubbard" -W -b"OU=Staff,OU=Users,OU=Accounts,DC=test,DC=local" -s sub "(objectClass=user)"标签:php,active-directory,ldap,ldap-query
2023年6月21日发(作者:)
phpldap查找,php–LDAP过滤器–查找特定OU的所有⽤户我在使⽤LDAP搜索过滤器时遇到问题.我需要检索的是特定LDAP组的所有⽤户,即OU = Staff,OU = Users,OU = Accounts,DC =test,DC = local我的搜索是:(&(objectCategory=user)(OU=Staff,OU=Users,OU=Accounts,DC=test,DC=local))⽬前它没有返回任何结果.我错过了什么?解决⽅法:你必须做两件事>设置搜索的基础OU = Staff,OU = Users,OU = Accounts,DC = test,DC = local>使⽤objectClass搜索对象.使⽤PHP,搜索将如下所⽰(基于this PHP sample)://You must bind, first// using ldap bind$ldaprdn = 'yourdomainnic_hubbard'; // ldap rdn or dn$ldappass = 'password'; // associated password// connect to ldap server$ldapconn = ldap_connect("")or die("Could not connect to LDAP server.");if ($ldapconn) {// binding to ldap server$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);$dn = "OU=Staff,OU=Users,OU=Accounts,DC=test,DC=local";$filter="(objectClass=user)";$justthese = array("cn", "sn", "givenname", "mail");$sr=ldap_search($ldapconn, $dn, $filter, $justthese);$info = ldap_get_entries($ldapconn, $sr);echo $info["count"]." entries returnedn";}>您可以使⽤此命令在命令⾏上进⾏测试(确切的选项有所不同,这适⽤于最近的openldap的客户端⼯具):ldapsearch -H ldap:// -x -D "yourdomainnic_hubbard" -W -b"OU=Staff,OU=Users,OU=Accounts,DC=test,DC=local" -s sub "(objectClass=user)"标签:php,active-directory,ldap,ldap-query
发布评论