search PHP

I need to do research in AD-PHP with LDAP, but every time I do not have success.

I'm filtering by sAMAccountName. When I use a user with simple name ( Ex: printer) everything is ok but when the name is not simple ( Ex: paulo.neves) it does not work.

Any ideas?


    $usuario = "paulo.neves";

    $base_dn = "ou=Administradores, dc=tiisa, dc=com, dc=br";

    $filter = "(&(objectClass=user)(objectCategory=person)(cn=*)(samaccountname=$usuario))";

    if (!($search=@ldap_search($connect, $base_dn, $filter))) {
    die("Unable to search ldap server");
    }


Attribute values are defined in RFC4511. The octets that be used in an attribute value are defined by the syntax of the attribute type in question. If the syntax of samAccountName allows dot ( . ) characters without a requirement that said characters be escaped, then they need not be escaped.

It is always possible that the native language may require a character to be escaped.

  • Use the ldapsearch command line tool to verify that the entries with dots in the cn value can be retrieved from the directory

  • Just for grins, escape the dot in the attribute value by using " 2e " instead of " . " and see what happens.

  • probably not related to your problem, but if every entry has a cn attribute, there is no need to use the present filter component cn=* in the search filter

  • see also

  • Using ldapsearch

  • I'm willing to bet that . has to be escaped.

    链接地址: http://www.djcxy.com/p/60886.html

    上一篇: 将用户从LDAP导入Liferay

    下一篇: 搜索PHP