Monday, November 11, 2013

Some LDAP queries for common use

LDAP QUERIES

AD/GC FOR GROUPS THAT A USER IS MEMBER OF

1. Find the DN of the user e.g.
CN=Rajan Katwal,CN=Users,DC=katwal,DC=local

2.Use the DN into following query
(&(objectCategory=group)(member=CN=Rajan Katwal,CN=Users,DC=katwal,DC=local))

------------------------------------------------------------------------------------------------

USERS MEMBER OF A SPCIFIC GROUP

(&(objectcategory=user)(memberof=CN=Katwal_DL,CN=Users,DC=katwal,DC=local))

------------------------------------------------------------------------------------------------

USERS WITH SPECIFIC DISPLAY NAME

(&(objectclass=Person)(displayName= Rajan*))

------------------------------------------------------------------------------------------------

ALL ACTIVE (Non-Disabled) users from AD

(&(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2))

------------------------------------------------------------------------------------------------
GET all user of a group but will exclude user with display name starting with "user"

(&((objectclass=user)(memberOf=cn=Group1,ou=ouOfGroup,dc=subdomain,dc=domain,dc=com))(!(|((displayname=user*)))))



No comments: