Windows Active Dictionary与CSVDE介绍

来源:互联网 发布:淘宝店怎么修改标题 编辑:程序博客网 时间:2024/04/29 22:41
CSVDE 全称为 Comma Separated Value Data Exchange。CSV(comma-separated value)文件实际上只是一个将数据以逗号分隔的文本文件。CSVDE可以在不影响当前配置的情况下导出AD配置信息,也可以将AD配置导入到一个新安装的AD中。将AD配置导入到正在使用的域中将会直接影响整个系统,因此最好仅在测试环境中进行导入实验。

一、导出

导出所有AD配置:

csvde -f output.csv

-r: 按LDAP字段过滤

仅一个条件时:
csvde -f users.csv -r "objectCategory=person"
多个条件相“与”:
输出属于user对象类型,并且类别为person的所有项目:
csvde -f users.csv -r "(&(objectClass=user)(objectCategory=person))"
多个条件相“或”:
输出userAccountControl值为514或者546或者66050的所有项目:
csvde -f accountControl.csv -r "(|(useraccountcontrol=514)(useraccountcontrol=546)(useraccountcontrol=66050))"
{!}INFO:关于userAccountControl,请参考lesca博客《UserAccountControl基本属性、功能对照、常见功能组合》一文。

-d: 按DN中的字段过滤

关于DN的介绍请参考lesca博客的《什么是DN(Distinguished Names)》一文。下面举几个例子:
csvde -d "OU=TEST,DC=lesca,DC=bit" -f example.csv
csvde -d "CN=Users,DC=lesca,DC=bit" -f example.csv

-L: 指定LDAP输出字段

csvde -f example.csv -l "DN, objectClass, givenName, sn, name"

综合举例:

csvde -d "OU=Test,dc=lesca,dc=bit" -m -n -f example.csv -r objectClass=user -l "name, objectCategory, DN"
以下几个参数值的注意:
  • -m 用于排除诸如ObjectGUID, objectSID, pwdLastSet, samAccountType之类的属性
  • -n 禁止输出二进制值

二、导入

导入CSV到AD的指令很简单:
CSVDE -i -k -f test.csv
用Excel可以方便地生成CSV文件,具体操作方法可以见参考链接[1]和[3]。本节我们主要讨论CSV文件的结构。CSV至少需要三个字段:objectClass, sAMAccountName, DN。下表列出了这些必填字段的用途:

必填属性属性功能objectClass对象类型,通常为user。sAMAccountNameDomain\LogonName中的LogonName。此属性映射到用户界面中的 Windows 2000 以前版本的登录名,并且通常与用户登录名相同。DNDistinguished Names(了解更多)

除此以外,导入用户时还可以增加一些额外信息,下面罗列了其他常用可选属性的功能:

可选属性属性功能userAccountControl用户账户控制(了解更多)。将此属性的值设置为512。userPrincipalNameUPN,如lesca@lesca.bitgivenName名SN姓initials姓名缩写CN和DN中的CN字段相同(自动设置)name和CN相同(自动设置)description描述title职位名称department部门displayName显示名称。displayName 属性包含对象出现在全球通讯簿以及它所属的任何其他地址列表中时显示的名称。c国家代码,如CN表示中国co国家,如China(自动设置)st省l城市company公司名称mail用户电子邮件streetAddress公司街道地址postalCode邮政编码physicalDeliveryOfficeName办公地点telephoneNumber固定电话号码mobile移动电话号码facsimileTelephoneNumber传真号码ipPhoneIP电话wWWHomePage网站主页

这些必需的属性必须是 .csv 文件中的列标题,如下面的示例所示。

收起该表格展开该表格
objectClassDNdisplayNamesAMAccountNameuserAccountControluserdistinguished name of user objectNoMail UserNoMail User66048



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

ADSI Search---objectclass and objectcategory 

Object-Class:The list of classes from which this class is derived
Object-Category:An object class name used to groups objects of this or derived classes.
 

从网上摘抄的,objectclass与objectcategory的一般介绍 

Just to clarify, the objectClass attribute is multi-valued. Each object can inherit from one or more classes. User objects have objectClass equal to top, person, organizationalPerson, and user. Contact objects have objectClass equal to top, person, organizationalPerson, and contact. Computer objects have objectClass equal to top, person, organizationalPerson, user, and computer. Thus, a computer object has all of the attributes of a user object, plus some more inherited from the computer class. Computer objects are security principals just like user objects. They need to authenticate to the domain, have passwords (managed by the system), and can be granted permissions. The objectCategory attribute is single-valued. The value is a Distinguished Name. For user objects objectCategory is MyDomain.com is the domain. For contact objects objectCategory is the same, objects objectCategory is When searching AD for objects it is more efficient to use objectCategory because it is indexed (objectClass is not), but often a combination of objectClass and objectCategory must be used. The standard search filters are: For user objects: (&(objectCategory=person)(objectClass=user)) For contact objects: (&(objectCategory=person)(objectClass=contact)) For user and contact objects: (objectCategory=person) For computer objects: (objectCategory=computer) For group objects: (objectCategory=group) The provider translates (objectCategory=person) into the correct DN appropriate for the domain. Note that there is no such thing as (objectCategory=user), but the provider translates this into (objectCategory=person), so it includes contact objects. This may not be what you want. Another filter for user objects is: (sAMAccountType=80530636  

看了上面的解释,有点明白了在查询ADSI的时候为什么不建议用objectclass,而是建议用objectcategory,因为一个user的objectclass集成了好多,并不是唯一的,像我的账户在域中的objectclass就是top,person,organizationalPerson,user,而我的objectcategory就是CN=Person,CN=Schema,CN=Configuration,DC=ads-telekom,DC=de,这样查询起来范围就少多了

 

 

三、CSVDE的不足

  • 无法创建账户密码
  • 无法创建OU
 
0 0