漂亮蓝影 发表于 2018-6-20 12:46:19

windows 域的LDAP查询相关举例

windows 域的LDAP查询相关举例
  我记得你的需求是枚举单个ou下所有用户的相关信息。我帮你找了ldap的查询,但是没有发现有能满足你的需求的查询方式。当然了,我不是非常确定存在有我不知道的查询方式。
  不过有办法枚举出所有的domainusers
  使用(objectCategory=user)能查询当前域内所有的(包括禁用的)user以及contact的信息。
  下面是一些我觉得可能对你有用的查询代码:
  如果要寻找新创建的用户,可以使用(objectCategory=person)(whenCreated>=20081001000000.0Z)来查询2008年10月01日后创建的帐户。
  (objectCategory=person)(objectclass=user)(whenCreated>=20081001000000.0Z)可以排除contact
  如果你要查询不在某个组内的用户,你可以使用
  (objectCategory=user)(!memberof=CN=LAMP,OU=Organization,OU=Groups,OU=Ethos BeiJing,DC=ethos,DC=com,DC=cn)
  或者查询在某个组内的用户
  (objectCategory=user)(memberof=CN=LAMP,OU=Organization,OU=Groups,OU=Ethos BeiJing,DC=ethos,DC=com,DC=cn)
  更多一些的查询方式请自己尝试
  (|(department=Sales)(company=north)(description=north))
  (|(objectcategory=user)(objectcategory=group)(objectcategory=contact))(|(description=North*)(company=North*))
  (objectCategory=computer)
  (objectCategory=computer)(!description=*)
  (objectCategory=group)(!member=*)
  (objectCategory=group)(samaccountname=*service*)
  (objectCategory=group)(samaccountname=*admin*)
  (objCategory=group)(description=*)
  (objectCategory=group)(|(cn=Domain*)(cn=enter*))
  (groupType:1.2.840.113556.1.4.803:=4)
  (groupType:1.2.840.113556.1.4.803:=8)
  (groupType:1.2.840.113556.1.4.804:=14)
  (groupType:1.2.840.113556.1.4.804:=14)(!member=*)
  (objectCategory=person)(objectClass=user)(name=*)
  (objectCategory=person)(description=*service*)
  (objectCategory=person)(samaccountname=*service*)
  (objectCategory=person)(!employeeid=*)
  (objectCategory=person)(!scriptPath=*)
  (objectCategory=person)(!profilepath=*)
  (objectCategory=person)(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=65536)
  (objectCategory=person)(objectClass=user)(pwdlastset=0)(!userAccountControl:1.2.840.113556.1.4.803:=2)
  (objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2)
  (objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=16)
  (objectCategory=person)(mail=*)
  (objectCategory=person)(!mail=*)
  (objectClass=user)(email=*)
  (objectCategory=person)(whenCreated>=20080801000000.0Z)
  (objectCategory=person)(!cn=sara*)
  (objectCategory=person)(badPwdCount>=2)
  (objectCategory=person)(objectClass=user)(pwdLastSet<=127204308000000000)
  (objectCategory=person)(objectClass=user)(|(lastLogon=0)!(lastLogon=*))
  (objectCategory=user)(pwdLastSet=0)
  (objectCategory=user)(msNPAllowDialin=TRUE)
  (objectcategory=user)(cn=David*)
  (objectcategory=user)(|(cn=David*)(cn=Dana*))
  (objectcategory=user)(|(mobile=050*)(mobile=051*))
  (objectcategory=user)(userAccountControl:1.2.840.113556.1.4.803:=65536)
  (objectCategory=user)(memberof=CN=LAMP,OU=Organization,OU=Groups,OU=Ethos BeiJing,DC=ethos,DC=com,DC=cn)
页: [1]
查看完整版本: windows 域的LDAP查询相关举例