我在将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