我需要更改用户的主要组,这样我就可以删除它从它的当前之一。但我的组不具有属性primaryGroupToken,这是我需要的,以改变用户的主组。下面是属性编辑器的截图:
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:
很显然,我的code没有响应:
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()
有没有办法手动设置呢?或者是有什么毛病我的code?先谢谢了。
Is there a way to manually set it? Or is there something wrong with my code? Thanks in advance.
推荐答案
这是一个计算的属性。从这里偷,你只需要将呼叫添加到 RefreshCache
访问属性之前:
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()
(没有测试过,我VB是有点生疏)
(Not tested, my VB is a bit rusty)
相关推荐
最新文章