AD域相關的屬性和C#操作AD域


 “常規標簽 

 Sn 
 Givename 
英文縮寫 Initials 
顯示名稱 displayName 
描述 Description 
辦公室 physicalDeliveryOfficeName  
電話號碼 telephoneNumber 
電話號碼:其它 otherTelephone 多個以英文分號分隔 
電子郵件 Mail 
網頁 wWWHomePage 
網頁:其它 url 多個以英文分號分隔

地址標簽 

國家/地區 C 如:中國CN,英國GB 
/自治區 St  
/ L 
街道 streetAddress 
郵政信箱 postOfficeBox 
郵政編碼 postalCode 

帳戶標簽 

用戶登錄名 userPrincipalName 形如:pccai1983@hotmail.com 
用戶登錄名(以前版本) 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 
由呼叫方設置或回撥到 值:
總是回撥到 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;

                            }

                   }

 

文檔下載

源代碼下載(代碼馬上就來)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM