Benjamin Kalytta
2008-04-07 04:54:14 UTC
Hello there,
I'm trying to determine the Organization Unit of a given Computer.
I found an Interface that should be capable of doing this which is IADsADSystemInfo.
Creating an Instance works fine, but as soon as I call get_ComputerName the
result is always 80070005 (Access denied). I'm using Windows Vista as Client and
joined a Domain on a Windows 2003 Standard Server. Locally I'm an Administrator
and running this tool as "Administrator" (Run as...).
The code:
CoInitialize(NULL);
HRESULT hr = CoCreateInstance(__uuidof(ADSystemInfo), NULL,
CLSCTX_INPROC_SERVER, __uuidof(IADsADSystemInfo), (void**) &pADsys);
if(SUCCEEDED(hr)) {
BSTR Computer = 0;
hr = pADsys->get_ComputerName(&Computer);
if (SUCCEEDED(hr)) {
// Do something here
SysFreeString(Computer);
} else {
// Print Error code here (80070005 in my case)
}
...
}
CoUninitialize();
What I'am doing wrong here? Is there something that I missed to initialize? This
example can be found in Windows SDK help for example in
ms-help://MS.MSDNQTR.v90.en/adsi/adsi/iadsadsysteminfo_property_methods.htm
Is it required to call CoInitializeSecurity in some way?
Regards,
Benjamin Kalytta
I'm trying to determine the Organization Unit of a given Computer.
I found an Interface that should be capable of doing this which is IADsADSystemInfo.
Creating an Instance works fine, but as soon as I call get_ComputerName the
result is always 80070005 (Access denied). I'm using Windows Vista as Client and
joined a Domain on a Windows 2003 Standard Server. Locally I'm an Administrator
and running this tool as "Administrator" (Run as...).
The code:
CoInitialize(NULL);
HRESULT hr = CoCreateInstance(__uuidof(ADSystemInfo), NULL,
CLSCTX_INPROC_SERVER, __uuidof(IADsADSystemInfo), (void**) &pADsys);
if(SUCCEEDED(hr)) {
BSTR Computer = 0;
hr = pADsys->get_ComputerName(&Computer);
if (SUCCEEDED(hr)) {
// Do something here
SysFreeString(Computer);
} else {
// Print Error code here (80070005 in my case)
}
...
}
CoUninitialize();
What I'am doing wrong here? Is there something that I missed to initialize? This
example can be found in Windows SDK help for example in
ms-help://MS.MSDNQTR.v90.en/adsi/adsi/iadsadsysteminfo_property_methods.htm
Is it required to call CoInitializeSecurity in some way?
Regards,
Benjamin Kalytta