WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: NotThatSteve on June 05, 2015, 06:45:09 AM

Title: Read attribute msExchMailboxGuid to string
Post by: NotThatSteve on June 05, 2015, 06:45:09 AM
I am using dsGetProperty to get the values of multiple Active Directory attributes of user objects.  Most of the return usable strings but msExchMailboxGuid returns 16 numbers instead of the GUID.  Is there a function to easily convert this to a string?  Otherwise is there a better function in winbatch to get that value into a string? 

Thanks in advance!
Title: Re: Read attribute msExchMailboxGuid to string
Post by: td on June 05, 2015, 09:20:25 AM
The 'msExchMailboxGuid' property is an octet string type in AD's schema.  The extender defaults to returning octet string properties as a space delimited list of byte value. The extender does maintain a table of properties that it will convert from octet string to other representations but this property isn't one of them so it uses the default representation. 

There are multiple ways to obtain the string GUID representation from a  list. Here is but one:
Code (winbatch) Select
AddExtender("wilx44i.dll",0,"wilx64i.dll")
strOctet = '0 170 197 107 205 68 17 208 140 194 0 192 79 194 149 238'
nMax = ItemCount(strOctet, ' ')
strGuid = "{"
for i = 1 to nMax 
   strGuid := StrFixLeft(xBaseConvert(ItemExtract(i, strOctet, ' '), 10, 16), '0', 2)
   if i == 4 || i == 6 || i == 8 || i == 10 then strGuid := '-'
next
strGuid := '}'

Message( "String Guid", strGuid)
Title: Re: Read attribute msExchMailboxGuid to string
Post by: NotThatSteve on June 05, 2015, 10:05:01 AM
Excellent.  That put me on the right track.  I appreciate your quick help.