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. . . .


Viktors Judins March 23, 2004