Function: Parse Object Name from Path
Posted by Scott Horsfield - 15/04/08 at 12:04:37 pmThe following function will allow you to pull an object name from a path:
Example: LDAP:\\CN=JSMITH, OU=USERS, DC=DOMAIN, DC=COM
The function will return JSMITH. This may not seem very useful at first, and I created it only after I was unable to return results of anthing but the path. This is also useful in scripts that need both the path and the object name and can be used to remove the need for multiple queries. Function posted after the break.
Function getServerNameFromPath(inputString)
Dim textValue
textValue = inputString
Dim textLength
textLength = Len(textValue)
textValue = Right(textValue, textLength-10)
Dim searchChar
searchChar = “,”
Dim searchCharPosition
searchCharPosition=Instr(1, textValue, SearchChar, 1)
textLength = Len(textValue)
textValue = Left(textValue, SearchCharPosition-1)
getServerNameFromPath = textvalue
End Function
2 Comments »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Powered by WordPress with [GimpStyle]
Entries and comments feeds.
Why not simply use the IADsPathname interface to extract various elements of the path?
Comment by SteveG — May 14, 2009 #
No reason other than I’ve never used IADSPathname, though after looking into it you’re spot on. It would probably better to use in this case, less chance of error when manipulating the strings. Thanks for the tip! And thanks for replying to the posts, I appreciate the feedback and suggestions for improving them.
Comment by Scott Horsfield — May 14, 2009 #