“new DirectoryEntry(distinguishedName as string)” doesn't work when DN contains a “/”

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)

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)

Need Your Help

system() function under cygwin

cygwin eclipse-cdt

I develop a console program(C++) that use Cygwin and eclipse cdt. In application I have used system() function. But when I build to executable file and copy file cygwin.dll into running directory, ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.