1

我正在尝试获取信息(组成员)。

每次我收到消息“无法检索有关域的信息 (1355)”

为了获得团体,它只尝试了 2 次。第一次不起作用,但第二次给我带来了团体。但是为了获得一个组的成员,我没有工作。

        PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "192.168.178.105:3268", "DC=ibcdev,DC=local", ContextOptions.Negotiate, "Administrator", "123");
        // define a "query-by-example" principal - here, we search for a GroupPrincipal 
        GroupPrincipal qbeGroup = new GroupPrincipal(ctx);

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

        // find all matches
        try
        {
            var re2s = srch.FindAll().ToList();
        }
        catch (Exception)
        {
        }
        var res = srch.FindAll();
        foreach (Principal found in res)
        {
            Console.WriteLine(found.SamAccountName);
            var group = GroupPrincipal.FindByIdentity(ctx, found.Name);
            foreach (var user in group.Members)
            {
                Console.WriteLine(user.SamAccountName);
            }
        }

有人知道我做错了什么吗?

问候

4

1 回答 1

0

这是我用于在域中查找组成员的方法:

public List<String> GetIDs(string domainName, string groupName)
{
    using(PrincipalContext ctx = new PrincipalContext(ContextType.Domain, domainName))
    using(GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx, IdentityType.Name, groupName))
        return (from x in grp.GetMembers(true).AsParallel() select x.SamAccountName).ToList();
}
于 2013-10-01T15:24:24.597 回答