Microsoft KB Archive/325649

= How to retrieve the GUID of an object from the Active Directory =

Article ID: 325649

Article Last Modified on 3/29/2007

-

APPLIES TO


 * Microsoft Windows 2000 Standard Edition
 * Microsoft Active Directory Service Interfaces 2.5
 * Microsoft Active Directory Service Interfaces 2.5

-



This article was previously published under Q325649



SUMMARY
This article demonstrates how to convert the hexadecimal string form of an object's GUID into its string form:   Paste the following code in a .vbs file. '================================================================ 'Set the next line to reflect a DN for an object in the directory '================================================================ Set obj = GetObject(&quot;LDAP://CN=Username,CN=Users,DC=DOMAIN,DC=COM&quot;) MsgBox &quot;The GUID string Value for user &quot; & obj.Get(&quot;DisplayName&quot;) & _ &quot; is &quot; & ConvertHexStringGUIDToStringGUID(obj.GUID)

'================================================================ ' ConvertHexStringGUIDToStringGUID function '================================================================ Function ConvertHexStringGUIDToStringGUID(strOctet) Dim tmpGUID, GUIDStr 'Convert the string by flipping the bits around. GUIDStr = Mid(strOctet, 7, 2) GUIDStr = GUIDStr + Mid(strOctet, 5, 2) GUIDStr = GUIDStr + Mid(strOctet, 3, 2) GUIDStr = GUIDStr + Mid(strOctet, 1, 2) GUIDStr = GUIDStr + Mid(strOctet, 11, 2) GUIDStr = GUIDStr + Mid(strOctet, 9, 2) GUIDStr = GUIDStr + Mid(strOctet, 15, 2) GUIDStr = GUIDStr + Mid(strOctet, 13, 2) GUIDStr = GUIDStr + Mid(strOctet, 17, Len(strOctet))

tmpGUID = &quot;{&quot; & Mid(GUIDStr, 1,  8) & &quot;-&quot; & Mid(GUIDStr,  9, 4) & _ &quot;-&quot; & Mid(GUIDStr, 13, 4) & &quot;-&quot; & Mid(GUIDStr, 17, 4) & _ &quot;-&quot; & Mid(GUIDStr, 21, 15) & &quot;}&quot;

ConvertHexStringGUIDToStringGUID = tmpGUID End Function

 Run the script.

Keywords: kbhowtomaster kbdswadsi2003swept KB325649

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.