Thursday, February 10, 2011

LDAP / AD script stuff

Given an LDAP distinguishedName (dn) value, such as "CN=JohnDoe,OU=Sales,OU=Users,OU=Corporate,DC=contoso,DC=msft" you can strip out just the value assigned to the first CN= set using VBscript as follows:

CleanName = Replace(Split(DN,",")(0), "CN=", "")

This will return "JohnDoe"
Post a Comment