尝试在 Active Directory 中创建嵌套安全组
我正在尝试使用以下代码在活动目录中创建嵌套安全组:
DirectoryEntry newContainer = dirEntry.Children.Add("CN=" + groupName, "group");
newContainer.Properties["description"].Value = groupId;
GrpType gt = GrpType.GlobalGrp | GrpType.SecurityGrp;
int typeNum = (int)gt;
newContainer.Properties["groupType"].Add(typeNum);
newContainer.Properties["sAMAccountName"].Add(groupName);
newContainer.CommitChanges();
创建第一级组时没有问题,但是当我尝试在这些组内创建子安全组时,我得到一个“< strong>命名违规”错误,没有进一步的答案。
顺便说一下,我可以手动创建这些安全组。
I'm trying to create nested security groups in an active directory, with the following code:
DirectoryEntry newContainer = dirEntry.Children.Add("CN=" + groupName, "group");
newContainer.Properties["description"].Value = groupId;
GrpType gt = GrpType.GlobalGrp | GrpType.SecurityGrp;
int typeNum = (int)gt;
newContainer.Properties["groupType"].Add(typeNum);
newContainer.Properties["sAMAccountName"].Add(groupName);
newContainer.CommitChanges();
I get no problem when creating the first level groups, but when I try to create a sub-security group inside these groups, I get a "Naming violation" error, with no further answer.
And by the way, I can manually create those security groups.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您可以在以下位置找到的帮助: Howto: (Almost) Everything In Active Directory via C#
以下是您想要使用 ADSI 执行的操作的示例:
使用 安全主体随 Framework .NET 3.5 一起引入可以以最短的方式做同样的事情,请参阅:管理 .NET Framework 3.5 中的目录安全主体
According to the help you can find in : Howto: (Almost) Everything In Active Directory via C#
Here is an example of what you want to do whith ADSI :
With Security Principals introduced with Framework .NET 3.5 you can do the same thing in a shortest way see : Managing Directory Security Principals in the .NET Framework 3.5
我稍后会回来,然后也许会有更好的代码
I will back later with it and then maybe better code