ldap基本dn_LDAP查询基础

下面的是一些LDAP语法的更加高级些的例子:

你需要一个filter来找到所有在Dallas或者Austin的对象, 并且first name还得是John. 这个filter应该是:

(&(givenName=John)(|(l=Dallas)(l=Austin)))

你已经在Application log中收到了9548个event, 你需要找到所有的引发这个日志事件的对象. 在这种情况下, 你需要找到所有的被disable的user, (msExchUserAccountControl=2) 并且在msExchMasterAccountSID这个属性上没有值.

(&(msExchUserAccountControl=2)(!msExchMasterAccountSID=*))

The ! operator in conjunction with the wildcard operator will look for objects where that attribute is not set to anything.

注意. ! 操作符跟通配符连接在一起, 会寻找属性没被设为任何值的对象.

在哪里使用LDAP查询呢?

==============

在与Exchange服务器一起工作的时候, 你会遇到使用LDAP字符串的情形. 比如说, 无论何时, 你设置一个接受者, 或者mailbox管理者策略, 或者一个地址列表filter, 或者当你搜索Active Directroy目录服务的时候, Exchange服务器都会使用LDAP. 在下一个部分, 会讨论一些你可以使用LDAP语句的方法:

一. 使用Active Directory Users and Computers进行搜索

下面的例子描述了如何使用Active Directory Users and Computers进行搜索:

1. 打开Active Directory Users and Computers (Win + R, dsa.msc)

2. 右键点击域对象(domain object), 然后选择Find.

fd9bcc30bcb6bc13d99f3f71ba6ed314.gif

3. 点击紧挨着Find的下拉列表, 然后选择Custom Search.

4. 在下面的屏幕中, 选择Advanced 选项卡.

5. 在Enter LDAP query下面输入恰当的LDAP语句.

1147f077af276d5bb8597d4e964a5372.gif

这个例子会试图寻找所有满足下面条件的对象: 他们的title属性是prez, 或者他们的名字由test开始. 如果你点击Find Now, 你应该看到恰当的输出结果, 请看下面的截屏:

4e8b66a7368634deddd7d371cc7c39d8.gif

二. 使用LDP进行搜索

你还可以使用LDP进行搜索, 这个工具包含在Microsoft Windows Server™ 2003 和 Windows® 2000 Server support tools中. 这个工具给予你不仅仅是搜索domain container的能力, 还有搜索Configuration container的能力. 你首先会打开LDP, 然后连接到合法的domain controller上. 然后你需要使用合适的credential来绑定. 选择View,然后选择Tree. 保持Base DN栏为空, 点击OK.导航到你想要搜索的container上, 右击container, 然后选择Search.

e412ee3d1856a0a2682565a4930e290e.gif

一个对话框会tanchu,其中会包含Base DN的正确值. 输入你想要filter过滤的LDAP语句, 像前面那样的结果应该会出现的.

85ec18d2e97444098d15183a047cd2aa.gif

如果你想要搜索你当前所在的containter下面的所有层次, 你需要确保选项Subtree被选中. 点击Run, 它应该会找到所有满足条件的结果.

三. 使用LDIFDE搜索

你需要为获取一个满足某种条件的对象集而进行查询, 而且你希望建立一个这些user的列表. LDIFDE是一个命令行工具, 它可以帮助你建立这样的列表. 假设你希望找到并保存所有mailNickName 以Jeff开始的用户列表. 你可以运行下面的命令.

C:\>ldifde -d "DC=witaylorroot,DC=com" -f c:\output.txt -r "(&(objectClass=user)(mailNickName=jeff*))

在这个例子里, 你将会找到三个对象, 然后输出所有他们的属性到output.txt文件中. 如果你输出近千个用户的结果, 输出结果文件就会变得非常庞大. 还有另一个不同的选项. 你可以使用-l(小写的L)开关来指定要输出那些属性. distinguished name 永远会被输出的, 但是如果你不想要其他的东西, 你可以添加-l nothing到字符串后面, 这会streamline 输出结果. 下面就是一个例子:

C:\>ldifde -d "DC=witaylorroot,DC=com" -f c:\output.txt -l nothing -r "(&(objectClass=user)(mailNickName=jeff*))

Consider that in this case, you want to use the LDIFDE export referenced earlier, but only want to include the homeMDB attribute in the output. You must use the following command.

如果你想要包括homeMDB 属性到结果中. 那么你就要运行下面的命令:

C:\>ldifde -d "DC=witaylorroot,DC=com" -f c:\output.txt -l "homeMDB" -r "(&(objectClass=user)(mailNickName=jeff*))

dn: CN=jeff,OU=55Users,DC=witaylorroot,DC=com changetype: add homeMDB: CN=Private Information Store (WITAYLORNT4EX55),CN=First Storage Group,CN=InformationStore,CN=WITAYLORNT4EX55,CN=Servers,CN=WITAYLORMIXEDSITE,CN=Administrative Groups,CN=WITAYLORORG,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=witaylorroot,DC=com

dn: CN=jeff2,CN=Users,DC=witaylorroot,DC=com changetype: add homeMDB: CN=Private Information Store (WITAYLORNT4EX55),CN=First Storage Group,CN=InformationStore,CN=WITAYLORNT4EX55,CN=Servers,CN=WITAYLORMIXEDSITE,CN=Administrative Groups,CN=WITAYLORORG,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=witaylorroot,DC=com

dn: CN=jeff3,CN=Users,DC=witaylorroot,DC=com changetype: add homeMDB: CN=Private Information Store (WITAYLORNT4EX55),CN=First Storage Group,CN=InformationStore,CN=WITAYLORNT4EX55,CN=Servers,CN=WITAYLORMIXEDSITE,CN=Administrative Groups,CN=WITAYLORORG,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=witaylorroot,DC=com

如果你进行一个输出操作而不指定哪些属性被输出, 你就会想要使用-n开关来去掉普通情形下被包括进来的值. 这会帮助防止输出文件变得过大.

四, 在ADModify中使用LDAP查询

译注: 这个工具不常用, 还得上case才能拿到这个工具, 就不翻译了. 列在这里.

To obtain the ADModify tool, contact Microsoft Product Support Services. For more information about how to contact Microsoft Product Support Services, see the Microsoft Help and Support Web site.

To obtain the ADModify tool from a third-party Web site, see the following GotDotNet Web site: ADModify.NET: Workspace Home.

ADModify is a tool that Microsoft Product Support Services uses on a daily basis. With large Active Directory environments, it is not always easy to add an entire organizational unit (OU) that could have thousands of users in it to the list on the right side, and then parse through all of them to find the users you need to change. There is an alternative. On the first screen, choose Modify Existing User Attributes and click Next. On the Modify Active Directory Users screen, there is an Advanced button.

Aa996205.ea1873c7-1788-4944-b98d-5c58ba92f20a(en-us,EXCHG.65).gif

If you click the Advanced button, the Custom LDAP Filter dialog box appears. In this dialog box, you type the LDAP filter that you want to use. In this example, you only want to list the groups that are mail-enabled. It would look like the following.

Aa996205.677989cc-e781-469a-86bf-d1a05135f7da(en-us,EXCHG.65).gif

Next, click OK. Select the OU or the domain where you want ADModify to search. If you want it to look in lower-level containers within the one you selected, make sure to select Traverse Subcontainers when Enumerating Users. Click Add to List,and then click Yes when warned about how long it could take. The objects that meet the criteria you specified should now appear in the right pane.

Aa996205.4a9d4478-2af1-4083-9c5f-000d53784034(en-us,EXCHG.65).gif

From here, highlight the objects that you want to modify, and continue with the wizard.

译自:

LDAP Query Basics

链接:

LDIFDE - Export / Import data from Active Directory - LDIFDE commands

http://support.microsoft.com/kb/555636/en-us

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值