IADs *pobjADs; // Pointer to object interface
BSTR bstrName; // String with object name
HRESULT hResult; // COM result code
// String to directory service
WCHAR *pstrADsPath = "LDAP://ldap.itd.umich.edu/O=University of Michigan,C=us";
// Initalize COM
CoInitialize ( NULL );
// Get pointer to object's IADs interface
hResult = ADsGetObject( pstrADsPath, IID_IADs, (void**) &pobjADs);
// Check for success
if ( SUCCEEDED ( hResult ) )
{
// Get the Name property from the object
hResult = pobjADs->get_Name ( &bstrName );
// Check for success
if ( SUCCEEDED ( hResult ) )
{
// Display Name property
// (must use wide strings when working with COM)
wcout << "The name of the object found is: << bstrName << endl;
}
else
{
wcerr << L"Error occured while getting the object name: " << hResult << endl;
}
// When finished with the interface, call the
// Release method to free object
pobjADs->Release ();
}
else
{
wcerr << L"Error occured while getting the object: " << hResult << endl;
}
// Unload COM
CoUninitialize ();
// Return the result of any failures
return hResult;
; Compiler en UNICODE
Procedure Test(pstrADsPath.s)
Protected pobjADs.IADs; // Pointer to object interface
Protected *bstrName.l; // String with object name
Protected hResult.l; // COM result code
;// Initalize COM
CoInitialize_ ( #Null )
;// Get pointer To object's IADs interface
hResult = ADsGetObject_( pstrADsPath, ?IID_IADs, @pobjADs)
;// Check For success
If hResult = 0
*bstrName=SysAllocString_(Space(255))
;// Get the Name property from the object
hResult = pobjADs\get_Name(@*bstrName )
;// Check For success
If hResult=0
;// Display Name property
;// (must use wide strings when working With COM)
MessageRequester("Info","The name of the object found is: "+PeekS(*bstrName))
;// When finished With the Interface, call the
;// Release method To free object
pobjADs\Release ()
Else
MessageRequester("Info","Error occured While getting the object name: "+Str(hResult))
EndIf
SysFreeString_(*bstrName)
Else
MessageRequester("Info","Error occured While getting the object: "+Str(hResult))
EndIf
;// Unload COM
CoUninitialize_()
;// Return the result of any failures
ProcedureReturn hResult
EndProcedure
;// String To directory service
pstrADsPath.s = "LDAP://ldap.itd.umich.edu/O=University of Michigan,C=us"
;pstrADsPath.s ="LDAP:"
Debug test(pstrADsPath)
DataSection
IID_IADs:
Data.l $FD8256D0
Data.w $FD15, $11CE
Data.b $AB, $C4, $02, $60, $8C, $9E, $75, $53
EndDataSection