jarek.jpa
jarek.jpa

Reputation: 595

LDAP search with custom attributes filter

I'm having problems with finding a specific entry in LDAP tree, given a filter defined on a custom attribute.

I.e. (search by samaccountname=jpa)

ldapsearch -x -D "CN=admin,DC=my,DC=com" -w admin -H ldap://localhost:10389 -b "ou=My Users,dc=my,dc=com" -s sub "samaccountname=jpa" does not work (returns no result)

whereas (search sn=jpa):

ldapsearch -x -D "CN=admin,DC=my,DC=com" -w admin -H ldap://localhost:10389 -b "ou=My Users,dc=my,dc=com" -s sub "sn=jpa" works

even (check for existence of samaccountname):

ldapsearch -x -D "CN=admin,DC=my,DC=com" -w admin -H ldap://localhost:10389 -b "ou=My Users,dc=my,dc=com" -s sub "samaccountname=*" works

Any ideas what can be wrong here? My intention is to find the given user using sub (samaccountname=jpa) filter

My config is (using osixia/openldap docker image):

schema:

attributetype ( 1.2.840.113556.1.4.221 NAME 'sAMAccountName'
    SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
    SINGLE-VALUE
    USAGE userApplications )

objectclass ( 2.5.6.30 NAME 'extendedUser'
    SUP person
    STRUCTURAL
    MUST ( sAMAccountName ) )

ACL's:

dn: olcDatabase={1}mdb,cn=config
changetype: modify
delete: olcAccess
-
add: olcAccess
olcAccess: to * by * read

LDIF:

DN: OU=My Users,DC=my,DC=com
OU: My Users
objectClass: organizationalUnit

DN: CN=jpa,OU=My Users,DC=my,DC=com
CN: jpa
sn: jpa
sAMAccountName: jpa
objectClass: extendedUser
userPassword: xxx

Upvotes: 2

Views: 4103

Answers (1)

You need to define an EQUALITY on your attribute. LDAP doesn't currently know how to perform the search on that attribute.

attributetype ( 1.2.840.113556.1.4.221 NAME 'sAMAccountName'
    SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
    EQUALITY caseIgnoreMatch
    SINGLE-VALUE
    USAGE userApplications )

OpenLDAP Schema Specification

Upvotes: 3

Related Questions