我正在尝试将我们域上的网络组添加到机器上的本地管理员组。
我逐行调试,它找到了本地管理员组,它找到了网络组,但是当它到达这一行时:
AdministratorsGrp.Members.Add(NetworkGrp)
它返回错误“找不到网络路径”
我该如何解决这个错误,我花了 30 分钟搜索互联网并找不到解决方案:(
到目前为止,这是我的功能:
Private Function AddAdminGroup() As Boolean
Dim AdministratorsGrp As GroupPrincipal
Dim NetworkGrp As GroupPrincipal
Try
Dim DomainCtx As New PrincipalContext(ContextType.Domain, "<domainname>", "<username>", "<pw>")
'Find Local Administrators group by SID
AdministratorsGrp = GroupPrincipal.FindByIdentity(DomainCtx, IdentityType.Sid, "S-1-5-32-544")
'Find Desktop Managers group by Name on Domain
NetworkGrp = GroupPrincipal.FindByIdentity(DomainCtx, IdentityType.Name, "<network group")
'Add Desktop Managers group to Administrators Group
AdministratorsGrp.Members.Add(DesktopMGRGrp)
'Save Group
AdministratorsGrp.Save()
Return True
Catch PrinEx As PrincipalExistsException
Return True
Catch ex As Exception
End Try
Return False
End Function
提前感谢您提供的任何帮助!