我在將ASP.NET Web服務與Active Directory設置集成並將其用於身份驗證用戶並與AD組成員身份一起檢查時遇到問題,並且他們是否有有權使用我的自定義應用程序。獲取Active Directory中的用戶組
我的自定義應用程序有自己的權限,管理員配置允許使用自定義應用程序的Active Directory組。
我遇到的問題是,當來自不同可信AD林的用戶使用完全雙向信任嘗試登錄時,我無法從AD服務器獲取他的組的列表我的ASP.NET Web服務與...交流。 ASP.NET Web服務只能訪問AD服務器(AD Main),而不是AD控制器(AD Secondary)。
用戶是(AD Secondary)域的成員,並且我可以根據(AD Main)域對該用戶進行身份驗證,但我無法從(AD主域)域獲取組列表用戶位於(AD Secondary)域中。
我試過這段代碼。
StringCollection groupids = new StringCollection();
try
{
DirectoryLibrary dirLib = new DirectoryLibrary();
DirectoryEntry directoryEntry = new DirectoryEntry("LDAP://" + domain,username, password);
if (directoryEntry != null)
{
//Enum the properties so we can see what is in them
foreach (string propname in directoryEntry.Properties.PropertyNames)
{
Debug.WriteLine(propname);
}
object obGroups = directoryEntry.Invoke("Groups");
foreach (object ob in (IEnumerable)obGroups)
{
// Create object for each group.
DirectoryEntry obGpEntry = new DirectoryEntry(ob);
groupids.Add(obGpEntry.NativeGuid);
}
}
}
catch (DirectoryServicesCOMException ex) { throw ex; }
我試過從DirectoryEntry對象移開,就像這樣。
List<GroupPrincipal> result = new List<GroupPrincipal>();
StringCollection groupids = new StringCollection();
PrincipalContext yourDomain = new PrincipalContext(ContextType.Domain, domain, userName, password);
// find your user
UserPrincipal user = UserPrincipal.FindByIdentity(yourDomain, userName);
// if found - grab its groups
if (user != null)
{
PrincipalSearchResult<Principal> groups = user.GetGroups();
// iterate over all groups
foreach (Principal p in groups)
{
// make sure to add only group principals
if (p is GroupPrincipal)
{
groupids.Add(p.DisplayName);
}
}
}
但是,我沒有得到用戶,我無法獲得該用戶在其他域中的組列表。任何幫助,將不勝感激。
我[以前有(http://serverfault.com/questions/358102/inconsistent-information-in-active -directory-members-and-member-properties)與AD組成員關係的一個小世界。祝你好運,我只能說... – AakashM 2012-04-10 15:32:54
我們還沒有找到解決方案,但它看起來像我們要安裝ADFS – 2012-04-16 20:55:30