Subscribe to Windows IT Pro
February 12, 2004 12:00 AM

Rem: Retrieving the Value of the ObjectGUID Attribute

Windows IT Pro
InstantDoc ID #41507
Rating: (0)
Downloads
41507.zip

I'm trying to retrieve the value of an Active Directory (AD) user object's objectGUID attribute with the code that Listing 1 shows. But when I run this code, I receive a string of question marks, as Figure 1 shows. How can I retrieve this value?

The code to retrieve the objectGUID value can be amazingly simple or moderately complex. The simple solution uses the IADs::GUID helper property in lieu of accessing the objectGUID attribute directly. Listing 2 demonstrates how easy using the IADs::GUID property is. When you run the code in Listing 2, you should get output more to your liking, as the second entry in Figure 1 shows.

The moderately complex solution involves manually converting the objectGUID value to a string, as Listing 3 shows. Listing 3 should also produce the results you're looking for, as the third entry in Figure 1 shows.

Why does IADs::GUID work but objectGUID doesn't without jumping through hoops? IADs::GUID works because AD stores the objectGUID value as an octet string. An octet string is an array of bytes that's used to store binary data. When you use the IADs::GUID property to retrieve the objectGUID value, Active Directory Service Interfaces (ADSI) takes care of converting the octet string into a usable string for you. If you want to access objectGUID directly, converting the octet string into a usable string is up to you.

Related Content:

ARTICLE TOOLS

Comments
  • Viktors Judins
    8 years ago
    Mar 23, 2004

    Thanks! At this moment i have same trouble with objectGUID and now it's solved. But what about objectSID retrieving?

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.