AD: Group does not have a primaryGroupToken attribute

余生颓废 提交于 2019-12-11 19:12:44

问题


I need to change the primary group of a user, so I can delete it from it's current one. But my group does not have the attribute "primaryGroupToken", which I need in order to change the primary group of the user. Here is a screenshot of the attribute editor:

Obviously, my code responds nothing:

Dim domainGroup As New DirectoryEntry("LDAP://our.domain/CN=Domain Users,CN=Users,DC=our,DC=domain")
Dim domainGroupGroupToken As String = domainGroup.Properties("primaryGroupToken").Value.ToString()

Is there a way to manually set it? Or is there something wrong with my code? Thanks in advance.


回答1:


It's a computed property. Stealing from here, you just need to add a call to RefreshCache before accessing the property:

Dim domainGroup As New DirectoryEntry("LDAP://our.domain/CN=Domain Users,CN=Users,DC=our,DC=domain")
domainGroup.RefreshCache(New String() {"primaryGroupToken"})
Dim domainGroupGroupToken As String = domainGroup.Properties("primaryGroupToken").Value.ToString()

(Not tested, my VB is a bit rusty)



来源:https://stackoverflow.com/questions/15827491/ad-group-does-not-have-a-primarygrouptoken-attribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!