試圖讓所有用戶所屬的組,包括初級組:獲得初級組ID
做這樣的事情:
DirectoryEntry entry = new DirectoryEntry(LDAP:/domainXYZ, userx, passwordx);
DirectorySearcher searcher = new DirectorySearcher(entry);
searcher.Filter = String.Format("(&(objectClass=user)(userPrincipalName={0}{1}))", userY, LDAP://domainXYZ);
SearchResultCollection resultColln= searcher.FindOne();
string actualGroupName =string.empty;
string grp ="";
foreach (SearchResult singleRes in resultColln)
{
foreach (object value in singleRes.Properties["memberof"])
{
grp = value.ToString();
Console.WriteLine("group:{0} ", grp);
}
}
這使我除了主組中的所有組。有沒有辦法讓主組名稱,除了其他組使用primaryGroupID
?
這有幫助嗎? http://dunnry.com/blog/2005/01/18/DeterminingYourPrimaryGroupInActiveDirectoryUsingNET.aspx – RQDQ 2011-03-14 21:44:29