我正在尝试将用户添加到AD中的组,但是下面的示例代码不再起作用:
UserPrincipal insUserPrincipal = (UserPrincipal)lbUsers.SelectedItem;
GroupPrincipal groupPrincipal =
GroupPrincipal.FindByIdentity(insPrincipalContext, group.GroupName);
if (groupPrincipal.Members.Contains(insPrincipalContext,
IdentityType.SamAccountName, insUserPrincipal.SamAccountName))
{
MessageBox.Show(insUserPrincipal.Name +
" is already a member of group " + group.GroupName);
return;
}
groupPrincipal.Members.Add(insUserPrincipal);
groupPrincipal.Save();有人知道如何在asp.net Core2.2中做到这一点吗?我找不到新版本。
GroupPrincipal.FindByIdentity(insPrincipalContext, group.GroupName); //No longer exists编辑:我可以使用GroupPrincipal来搜索组等-但是缺少FindByIdentity方法
发布于 2019-02-21 22:09:46
为了在.NET核心上使用System.DirectoryServices.AccountManagement,您需要安装提供此功能的NuGet package with the same name。完成此操作后,您应该能够再次访问GroupPrincipal类型。
https://stackoverflow.com/questions/54806287
复制相似问题