Microsoft KB Archive/257999

{|
 * width="100%"|

BUG: IADs::PutEx Method Causes -2147467259 (0x80004005) Error

 * }

Q257999

-

The information in this article applies to:


 * Microsoft Active Directory Service Interfaces, version 2.5

-

SYMPTOMS
When you use the Active Directory Service Interfaces (ADSI) IADs::PutEx method (with the LDAP provider) to set a multi-valued integer property, you may receive a -2147467259 error or 0x80004005 "Unspecified Error". This problem occurs when you load multi-value integers into a DWORD array.

RESOLUTION
To work around this problem, load the multi-value integers into an LPWSTR array as demonstrated here:

#include 

void main{ HRESULT hr; IADs *pIADsObject=NULL; LPWSTR pszADsPath  = L"LDAP://SiteServer600:1239/o=AccessTest/ou=Members/cn=MyUser"; LPWSTR pszAdminPath = L"cn=Administrator, ou=Members, o=AccessTest"; LPWSTR pszAdminPass = L"password";

CoInitialize(NULL); hr = ADsOpenObject (pszADsPath,pszAdminPath, pszAdminPass,0,IID_IADs,                    (void**)&pIADsObject); VARIANT var; VariantInit(&var);

LPWSTR dwArray[5]={L"0",L"1",L"2",L"3",L"4"}; VARIANT varArray;

hr = ADsBuildVarArrayStr(dwArray, 5, &varArray);

if (FAILED(hr)) { exit(1); }

hr = pIADsObject->PutEx (ADS_PROPERTY_APPEND, L"OtherInts",varArray); VariantClear(&varArray);

hr = pIADsObject->SetInfo; VariantClear(&var);

CoUninitialize; }

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

This problem was corrected in Microsoft Windows 2000.

Steps to Reproduce Behavior
In Microsoft Visual C++, create a new project and paste the following code:

#include 

void main { HRESULT hr; IADs *pIADsObject=NULL; LPWSTR pszADsPath  = L"LDAP://SiteServer600:1239/o=AccessTest/ou=Members/cn=MyUser"; LPWSTR pszAdminPath = L"cn=Administrator, ou=Members, o=AccessTest"; LPWSTR pszAdminPass = L"password";

CoInitialize(NULL); hr = ADsOpenObject (pszADsPath,pszAdminPath, pszAdminPass,0,IID_IADs,                    (void**)&pIADsObject); VARIANT var; VariantInit(&var);

DWORD dwArray[5]={0,1,2,3,4}; VARIANT varArray;

hr = ADsBuildVarArrayInt(dwArray, 5, &varArray);

if (FAILED(hr)) {   exit(1); } //Fails on the next line with -2147467259 on the PutEx method. hr = pIADsObject->PutEx (ADS_PROPERTY_APPEND, L"OtherInts",varArray); VariantClear(&varArray);

hr = pIADsObject->SetInfo;

CoUninitialize; } Make the following changes to the code:


 * For pszADsPath, specify a valid path to the object that you want to modify.
 * For pszAdminPath, specify a valid path to a user that has privileges to change object properties.
 * For pszAdminPass, specify a valid password.

Link the project with the Activeds.lib and Adsiid.lib libraries.

Set a breakpoint on the following line:

hr=pIADsObject->PutEx Additional query words:

Keywords : kbADSI kbMsg kbVC kbGrpDSMsg _IK

Issue type : kbbug

Technology : kbAudDeveloper kbADSISearch kbADSI250