"新的DirectoryEntry(distinguishedName来为字符串)" /"当DN包含&QUOT不工作;字符串、来为、工作、DirectoryEntry

2023-09-08 12:37:44 作者:∞疯子也有疯子旳情调

我有以下的code到A的distinguishedName转换为sAMAccountName赋:

I have the following code to convert a distinguishedName to a sAMAccountName:

Dim de As New DirectoryEntry("LDAP://" & stringDN)
Return CType(de.Properties("samaccountname")(0), String)

它的每DN我通过它,除了一个伟大工程。我们有一个/它在我们的领域的AD组 - 称之为程序员/数据库管理员。该DN对这个群体是程序员/数据库管理员,OU =用户组,DC = MYDOMAIN,DC =本地。当我尝试使用这个DN作为stringDN上面,我得到未知错误(0x80005000)。

It works great for every DN I pass it, except for one. We have an AD group on our domain that has a "/" in it - call it "Programmers/DBAs". The DN for this group is "Programmers/DBAs,OU=User Groups,DC=mydomain,DC=local". When I try to use this DN as the stringDN above, I get a COMException of "Unknown error (0x80005000)".

每隔组/用户在我的领域工作得很好,而且我在我们的测试领域,其中重命名组,以便它不包含/可以解决问题重复的问题。但是,我不能做到这一点在生产,所以我卡住了。

Every other group/user in my domain works fine, and I've duplicated the issue on our test domain, where renaming the group so it doesn't contains a "/" resolves the problem. However, I'm not able to do this in production, so I'm stuck.

我可以逃脱这个/不知何故?我必须相信有解决这个的解决方案,使我能得到这个组的属性正确。

Can I escape this "/" somehow? I've got to believe there's a solution around this so that I can get the properties of this group properly.

推荐答案

您是否尝试过这样做的:

Have you tried doing:

Dim de As New DirectoryEntry("LDAP://" & stringDN.Replace( "/", "\/" ))
Return CType(de.Properties("samaccountname")(0), String)