2

我需要在第 1 层的特定组中找到所有嵌套组。我遇到的问题是下面的代码通常可以工作,但对于某些组却不能。

如果我使用 Windows 资源管理器搜索特定组(单击网络图标,然后单击“搜索 Active Directory”,我可以看到父组中的成员和嵌套组。但是通过使用 System.DirectoryServices.AccountManagement 的代码3.5 框架,var Groups = MyGroup.GetGroups();看不到某些组的嵌套组,我以为是权限的问题,但是如果我从上面提到的自己手动搜索中可以看到组内部,那么我假设从同一帐户运行的代码应该是也能看到同样的东西。我应该尝试一些不同的东西吗?

对于它的价值,我在 SSIS 包内的 Framework 3.5 之上使用脚本任务。同样在同一个包中,从用户原则对象而不是组原则搜索组工作正常。

为了清楚起见,当我运行这段代码时

     PrincipalContext AD = new PrincipalContext(ContextType.Domain, "ctx", "mypath");
     GroupPrincipal myGroup = GroupPrincipal.FindByIdentity(AD, "myparentgroup");
     var nestedgroups = myGroup.GetGroups();

“Nestedgroups”应该包含我的嵌套组时为空。

4

1 回答 1

2

The problem I had was I used var Groups = MyGroup.GetGroups(); when I should have used var Groups = MyGroup.GetMembers();. Putting that behind a link statement allowed me to get all the objects I was looking for because .GetMembers() includes users and groups. Hope that helps.

于 2015-09-30T13:45:14.213 回答