1. 程式人生 > >AD屬性對照表

AD屬性對照表

“常規”標籤
姓 Sn 
名 Givename 
英文縮寫 Initials 
顯示名稱 displayName 
描述 Description 
辦公室 physicalDeliveryOfficeName  
電話號碼 telephoneNumber 
電話號碼:其它 otherTelephone 多個以英文分號分隔 
電子郵件 Mail 
網頁 wWWHomePage 
網頁:其它 url 多個以英文分號分隔
“地址”標籤
國家/地區 C 如:中國CN,英國GB 
省/自治區 St  
市/縣 L 
街道 streetAddress 
郵政信箱 postOfficeBox 
郵政編碼 postalCode 
“帳戶”標籤
使用者登入名 userPrincipalName 形如:[email protected] 
使用者登入名(以前版本) sAMAccountName 形如:S1 
登入時間 logonHours  
登入到 userWorkstations 多個以英文逗號分隔 
使用者帳戶控制 userAccountControl (啟用:512,禁用:514, 密碼永不過期:66048) 
帳戶過期 accountExpires 
“配置檔案”標籤
配置檔案路徑 profilePath 
登入指令碼 scriptPath 
主資料夾:本地路徑 homeDirectory 
連線 homeDrive 
到 homeDirectory 
“電話”標籤
家庭電話 homePhone (若是其它,在前面加other。) 
尋呼機 Pager 如:otherhomePhone。 
行動電話 mobile 若多個以英文分號分隔。 
傳真 FacsimileTelephoneNumber  
IP電話 ipPhone 
註釋 Info 
“單位”標籤
職務 Title 
部門 Department 
公司 Company 
“隸屬於”標籤
隸屬於  memberOf  使用者組的DN不需使用引號, 多個用分號分隔  
“撥入”標籤 遠端訪問許可權(撥入或VPN) msNPAllowDialin 
允許訪問 值:TRUE 
拒絕訪問 值:FALSE 
回撥選項 msRADIUSServiceType 
由呼叫方設定或回撥到 值:4 
總是回撥到 msRADIUSCallbackNumber  

名:GivenName

屬性

顯示名稱

屬性名稱

First Name

givenName

Last Name

sn

Initials

initials

Description

description

Office

physicalDeliveryOfficeName

Telephone Number

telephoneNumber

Telephone: Other

otherTelephone

E-Mail

mail

Web Page

wwwHomePage

Web Page: Other

url

帳號屬性:

顯示名稱

屬性名稱

UserLogon Name

userPrincipalName

User logon name (pre-Windows 2000)

sAMAccountname

Logon Hours

logonHours

Log On To

logonWorkstation

Account is locked out

userAccountControl

User must change password at next logon

pwdLastSet

User cannot change password

N/A

Other Account Options

userAccountControl

Account Expires

accountExpires

地址屬性

顯示名稱

屬性名稱

Street

streetAddress

P.O.Box

postOfficeBox

City

l

State/Province

st

Zip/Postal Code

postalCode

Country/Region

c, co, and countryCode

成員屬性

顯示名稱

屬性名稱

Member of

memberOf

Set Primary Group

primaryGroupID

組織屬性

顯示名稱

屬性名稱

Title

title

Department

department

Company

company

Manager:Name

manager

Direct Reports

directReports

外型屬性

顯示名稱

屬性名稱

Profile Path

profilePath

Logon Script

scriptPath

Home Folder: Local Path

homeDirectory

Home Folder: Connect

homeDrive

Home Folder: To

homeDirectory

電話相關屬性

顯示名稱

屬性名稱

Home

telephoneNumber

Home: Other

otherTelephone

Pager

pager

Pager: Other

pagerOther

Mobile

mobile

Mobile: Other

otherMobile

Fax

facsimileTelephoneNumber

Fax: Other

otherFacsimileTelephoneNumber

IP phone

ipPhone

IP phone: Other

otherIpPhone

Notes

info

C#操作AD例子:

GetUserEntry

         public static DirectoryEntry GetUserEntryByAccount(DirectoryEntry entry, string account)

                   {

                            DirectorySearcher searcher = new DirectorySearcher(entry);

                            searcher.Filter = "(&(objectClass=user)(SAMAccountName=" + account + "))";

                            SearchResult result = searcher.FindOne();

                            entry.Close();

                            if (result != null)

                            {

                                     return result.GetDirectoryEntry();

                            }

                            return null;

                   }

Set Property

                   public static void SetProperty(DirectoryEntry entry, string propertyName, string propertyValue)

                   {

                            if (entry.Properties.Contains(propertyName))

                            {

                                     if (string.IsNullOrEmpty(propertyValue))

                                     {

                                               object o = entry.Properties[propertyName].Value;

                                               entry.Properties[propertyName].Remove(o);

                                     }

                                     else

                                     {

                                               entry.Properties[propertyName][0] = propertyValue;

                                     }

                            }

                            else

                            {

                                     if (string.IsNullOrEmpty(propertyValue))

                                     {

                                               return;

                                     }

                                     entry.Properties[propertyName].Add(propertyValue);

                            }

                   }

Get Property

         public static string GetProperty(DirectoryEntry entry, string propertyName)

                   {

                            if (entry.Properties.Contains(propertyName))

                            {

                                     return entry.Properties[propertyName].Value.ToString();

                            }

                            else

                            {

                                     return string.Empty;

                            }

                   }