You can use the IADsNameTranslate ADSI Utility Interface to translate a user's Active Directory name from one form to another. To see te Perl version of this script, see Translate Active Directory Names using PowerShell.
Accessing Active Directory objects directly, via the GetObject function, can be a pain since you generally need to know the distinguished name (DN) of the object (e.g. cn=myUser, ou=myOU, dc=myDomain, dc=com). What if you have an OU structure that is eight levels deep? Forget about it! You don't want to be typing DN's in by hand. Who's got time for that?
More likely, you may know the user's logon ID, or their display name, and you want your script to figure out what the DN is. In previous posts, I've shown how to use ADO searches to retrieve information about a user. You certainly can use that technique to search for a user, given their logon ID or display name, and return their DN from the search. However, there's a handy interface in ADSI just for this purpose.
Here's a script that makes use of the IADsNameTranslate utility interface. We input the user's NT4-style logon name (i.e. domain\username) and use the translator to get us other forms of the name, including the DN.