2014-11-21 66 views
0

你能告訴我它是否存在交換郵箱對象的DirectoryEntry屬性列表嗎?Exchange郵箱DirectoryEntry屬性列表

這裏是我的代碼示例:

// create your domain context 
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, ConfigurationManager.AppSettings["ADDomain"].ToString(), ConfigurationManager.AppSettings["ADUser"].ToString(), ConfigurationManager.AppSettings["ADPassword"].ToString()); 

// define a "query-by-example" principal - here, we search for all users 
UserPrincipalEXT qbeUser = new UserPrincipalEXT(ctx); 

// create your principal searcher passing in the QBE principal  
PrincipalSearcher srch = new PrincipalSearcher(qbeUser); 

// find all matches 
foreach (var found in srch.FindAll()) 
{ 
    if (found.GetUnderlyingObjectType() == typeof(DirectoryEntry)) 
    { 
     DirectoryEntry de = (DirectoryEntry)found.GetUnderlyingObject(); 
    }     
} 

我努力尋找我需要的屬性的名稱...

謝謝!

回答

1

DirectoryEntry.Properties屬於PropertyCollection。這暴露了可用於枚舉屬性的屬性,如PropertyNames

foreach (var name in de.Properties.PropertyNames) 
{ 
    Console.WriteLine(name); 
} 
+0

謝謝我的朋友!工作就像一個魅力:) – 2014-11-21 19:01:31

相關問題