查看所有属性在运行里输入adsiedit.msc
objectClass-----------top
cn-----------ceshi
sn-----------ceshi
memberOf--------------------用户所在的组
distinguishedName-----------CN=ceshi,OU=开发人员组,DC=ceshi,DC=ceshi,DC=ceshi
instanceType-----------4
whenCreated-----------2012/5/4 2:42:05
whenChanged-----------2012/5/4 2:42:05
displayName-----------ceshi
uSNCreated-----------System.__ComObject
uSNChanged-----------System.__ComObject
name-----------ceshi
objectGUID-----------System.Byte[]
userAccountControl-----------66048
badPwdCount-----------0
codePage-----------0
countryCode-----------0
badPasswordTime-----------System.__ComObject
lastLogoff-----------System.__ComObject
lastLogon-----------System.__ComObject
pwdLastSet-----------System.__ComObject
primaryGroupID-----------513
objectSid-----------System.Byte[]
accountExpires-----------System.__ComObject
logonCount-----------0
sAMAccountName-----------ceshi
sAMAccountType-----------ceshi
userPrincipalName-----------ceshi@ceshi.ceshi.ceshi
objectCategory-----------CN=Person,CN=Schema,CN=Configuration,DC=ceshi,DC=ceshi,DC=ceshi
nTSecurityDescriptor-----------System.__ComObject
homePhone-----------1
mobile-----------00000000000000000055
DirectorySearcher mySearcher = new DirectorySearcher(entryOU, "(objectclass=organizationalUnit)"); //查询组织单位
第二个参数是一个filter,也可以根据需求输入其它筛选条件,下面列出几个常用的
筛选条件 | 值 |
用户 | (&(objectCategory=person)(objectClass=user)) |
计算机 | (objectCategory=computer) |
组 | (objectCategory=group) |
联系人 | (objectCategory=contact) |
共享文件夹 | (objectCategory=volume) |
打印机 | (objectCategory=printQueue) |
用户属性扩充说明(含图文属性对照) |
示例中只对用户进行了读取了几个属性,用过AD域的应该都知道,用户的属性较多也比较常用。
下面通过AD域的用户详细信来对照一下相应的属性名
对应编号 选项卡对应项名 属性名 ① 姓(L) sn ② 名(F) givenName ③ 显示名称(S) displayName ④ 描述(D) description ⑤ 办公室(C) physicalDeliveryOfficeName ⑥ 英文缩写(I) initials ⑦ 电话号码(T) telephoneNumber ⑧ 电子邮件(M) ⑨ 网页(W) wWWHomePage ⑩ 电话号码-其它(O)... otherTelephone ⑪ 网页-其它(R)... url
对应编号 选项卡对应项名 属性名 ① 国家/地区(O) co ② 省/自治区(V) st ③ 市/县(C) l ④ 街道(S) streetAddress ⑤ 邮政信箱(B) postOfficeBox ⑥ 邮政编码(Z) postalCode
对应编号 选项卡对应项名 属性名 ① 用户登录名(U) userPrincipalName ② 用户登录名(Windows 2000 以前版本)(W) sAMAccountName
对应编号 选项卡对应项名 属性名 ① 家庭电话(M) homePhone ② 寻呼机(P) pager ③ 移动电话(B) mobile ④ 传真(F) facsimileTelephoneNumber ⑤ IP电话(I) ipPhone ⑥ 注释 info ⑦ 家庭电话-其它(O) otherHomePhone ⑧ 寻呼机-其它(T) otherPager ⑨ 移动电话-其它(B) otherMobile ⑩ 传真-其它(E) otherFacsimileTelephoneNumber ⑪ IP电话-其它(R) otherIpPhone
对应编号 选项卡对应项名 属性名 ① 公司(C) company ② 部门(D) department ③ 职务(J) title ④ 经理-姓名(N) manager ⑥ 直接下属(E) directReports
还有一些属性没有列出来,可以循环输出DirectoryEntry.Properties.PropertyNames来找
比如用objectsid这也是个用户比较重要的属性,在设置Windows共享时会用到!