Use the following syntax to retrieve all attributes required or allowed by an objectClass definition with the following syntax for requested attributes: @objectClassName. The example below provide examples of how to search for entries where:
- no attributes are retrieved
- all attributes are retrieved
- attributes required or allowed by the
inetOrgPersonobjectClass are retrieved - attributes required or allowed by the
posixAccountobjectClass are retrieved
Retrieve No Attributes
ldapsearch -h localhost -p 1389 \ -b uid=user.0,ou=people,dc=example,dc=com \ -s base '(&)' 1.1 dn: uid=user.0,ou=People,dc=example,dc=com
Retrieve All Attributes
ldapsearch -h localhost -p 1389 \ -b uid=user.0,ou=people,dc=example,dc=com \ -s base '(&)' dn: uid=user.0,ou=People,dc=example,dc=com objectClass: top objectClass: person objectClass: organizationalPerson objectClass: inetOrgPerson objectClass: posixAccount objectClass: shadowAccount postalAddress: Aaren Atp$91327 Broadway Street$Las Vegas, UT 08103 postalCode: 08103 uid: user.0 employeeNumber: 0 initials: AWA givenName: Aaren pager: +1 214 214 4195 mobile: +1 947 007 3231 cn: Aaren Atp sn: Atp telephoneNumber: +1 089 907 9947 street: 91327 Broadway Street homePhone: +1 457 787 9183 l: Las Vegas mail: user.0@example.com st: UT description: test description 1 uidNumber: 10000 gidNumber: 10000 homeDirectory: /export/home/user.0 loginShell: /bin/bash
Retrieve attributes from the objectClass inetOrgPerson
ldapsearch -h localhost -p 1389 \ -b uid=user.0,ou=people,dc=example,dc=com \ -s base '(&)' @inetOrgPerson dn: uid=user.0,ou=People,dc=example,dc=com objectClass: top objectClass: person objectClass: organizationalPerson objectClass: inetOrgPerson objectClass: posixAccount objectClass: shadowAccount postalAddress: Aaren Atp$91327 Broadway Street$Las Vegas, UT 08103 postalCode: 08103 uid: user.0 employeeNumber: 0 initials: AWA givenName: Aaren pager: +1 214 214 4195 mobile: +1 947 007 3231 cn: Aaren Atp sn: Atp telephoneNumber: +1 089 907 9947 street: 91327 Broadway Street homePhone: +1 457 787 9183 l: Las Vegas mail: user.0@example.com st: UT description: test description 1
Retrieve attributes from the objectClass posixAccount
ldapsearch -h localhost -p 1389 \ -b uid=user.0,ou=people,dc=example,dc=com \ -s base '(&)' @posixAccount dn: uid=user.0,ou=People,dc=example,dc=com objectClass: top objectClass: person objectClass: organizationalPerson objectClass: inetOrgPerson objectClass: posixAccount objectClass: shadowAccount uid: user.0 cn: Aaren Atp description: test description 1 uidNumber: 10000 gidNumber: 10000 homeDirectory: /export/home/user.0 loginShell: /bin/bash
Pingback: LDAP: Using ldapsearch « Diaries, Triumphs, Failures, and Rants