ldap 用户登录计算机,【转】使用“Active Directory 用户和计算机”进行LDAP语法搜索...

Filter

Because of the existence of the class inheritance hierarchy in the schema every object in Active Directory is in fact a member of many classes -- four or five on the average. For this reason, the objectClassindex is prohibitively large (for example, 4 n, where nis the number of objects in the system). In addition, objectClasshas poor selectivity for many possible class values. For example, a search filter of ( objectClass= securityPrincipal) returns every user and group object in the system.

On the other hand, objectCategoryusually refers to the most specific class in the object's class hierarchy. Although objectClasscan have multiple values, the attribute objectCategoryhas only one. Every Active Directory object has an objectCategoryattribute whose value is a classSchemaobject.

Every classSchemaobject has an attribute called defaultObjectCategory, which is the object category of an instance of the class if none is specified by the user. For most classes, the defaultObjectCategoryvalue is the class itself. In the search filter, you can specify objectCategory= X, where Xis the ldapDisplayNameof a class, and LDAP automatically expands the filter to objectCategory=. The objectCategoryattribute has a syntax of distinguished name, and LDAP automatically converts the value for objectCategoryto the distinguished name format. For example, if you use objectCategory=contact in the filter, the filter changes to objectCategory=cn=person,cn=schema,cn=configuration,dc= ("person" is the defaultObjectCategoryfor the class contact).

For more information about class inheritance,

Find all Computers that do not have a Description

Notice the "!" that means "NOT".

(objectCategory=computer)(!description=*)

Find all Groups that have a Description

(objCategory=group)(description=*)

Find all Groups that start with QA or HD

Notice the "|" that means "OR".

(objectCategory=group)(|(cn=QA*)(cn=HD*))

Find all Objects where Department, Company or Description is Sales

Notice the "|" that means "OR".

(|(department=Sales)(company=Sales)(description=Sales))

Find all Users created after 01.08.2004

(objectCategory=user)(whenCreated>=20040801000000.0Z)

Find all Users except Sara

Notice the "!" that means "NOT".

(objectCategory=user)(!cn=sara*)

Find all Users that are almost Locked-Out

Notice the ">=" that means "Greater than or equal to".

(objectCategory=user)(badPwdCount>=2)

Find all Users that are Disabled

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

Find all Users that are Disabled (another option)

(&(objectCategory=person)(objectClass=user)(lockoutTime>=1))

Find all Users that are members of QA Users Group in the Help Desk OU in the dpetri.net domain

(objectCategory=user)(memberOf=CN=QA Users,OU=Help Desk,DC=dpetri,DC=net)

Find all Users that have an E-Mail Address (not Exchange related)

(objectClass=user)(mail=*)

Find all Users that have an E-Mail attribute (Mail Enabled)

(objectClass=user)(email=*)

Find all Users that have not changed password since 05.02.2004

Note:Download thescript. to help you generate this date format.

(&(objectCategory=person)(objectClass=user)(pwdLastSet<=127204308000000000))

Find all Users that have never logged in at all

Notice the "|" that means "OR" and the "!" that means "NOT".

(&(objectCategory=person)(objectClass=user))(|(lastLogon=0)(!(lastLogon=*)))

Find all Users that must change password at next logon

(objectCategory=user)(pwdLastSet=0)

Find all Users with Dial-In permissions

(objectCategory=user)(msNPAllowDialin=TRUE)

Find all Users with First Name of David

(objectcategory=user)(cn=David*)

Find all Users with First Name of David or Dana

Notice the "|" that means "OR".

(objectcategory=user)(|(cn=David*)(cn=Dana*))

Find all Users with Mobile numbers 050 or 051

Notice the "|" that means "OR".

(objectcategory=user)(|(mobile=050*)(mobile=051*))

Find all Users with Password Never Expires set

(objectcategory=user)(userAccountControl:1.2.840.113556.1.4.803:=65536)

Find all Users, Groups or Contacts where Company or Description is North

Notice the "|" that means "OR".

(|(objectcategory=user)(objectcategory=group)(objectcategory=contact))(|(description=North*)(company=North*))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值