How do I access msExchRecipientTypeDetails Property Values through the ADSI LDAP Provider (Ole Db)
It’s been a while since my last Blog post… I’ve been traveling to Seattle to attend my first Microsoft TechReady conference.
Shortly before I left, one of my colleagues helped me solving a case where a user wrote some VB Script code to access Active Directory Objects using the ADSI LDAP Provider.
That sounds actually more complicated than it is under the covers:
The Active Directory Service Interfaces (ADSI) Lightweight Directory Access Protocol (LDAP) provider implements OLE DB interfaces that allow you to use ActiveX Data Objects (ADO) to access objects in LDAP compliant directories.
Further ADSI details are explained in the KB.
One thing that was new to me was how to debug a VB Script using Visual Studio. The answer to this is also pretty simple: just run cscript.exe //d //x so that the default debugger gets attached when the script executes.
Further script debugging details are explained in this KB.
Anyway the actual customer problem however was a bit tricky so I think it is a good idea to share the solution just in case you run into the same issue yourself sometime.
Problem:
When accessing the value field of the ado recordset for “msExchRecipientTypeDetails” just like
1: adoRecordSet.Fields("msExchRecipientTypeDetails").Value
The error “object doesn't support this property or method” is thrown even though the debugger watch windows indicates that there seems to be a value of an unknown type.
Cause:
The reason why this happens is because the actual type of the value that is returned is a 64bit integer as documented in
The script engine seems to marshal such types as IADsLargeInteger Interface as documented in
https://msdn.microsoft.com/en-us/library/aa706037(VS.85).aspx
Solution:
This interface has a separate property for the 32bit low and the high part of 64bit value so that you can access it from VBS.
1: adoRecordSet.Fields("msExchRecipientTypeDetails").Value.LowPart
Hope that helps you tackling your code issue. Feedback is appreciated…
Good Luck!