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



The information in this article applies to:

  • Microsoft Active Directory Service Interfaces 2.5

This article was previously published under Q257999

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 <activeds.h>

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 that this is a bug in the Microsoft products that are listed at the beginning of this article.

This problem was corrected in Microsoft Windows 2000.

MORE INFORMATION

Steps to Reproduce Behavior

  1. In Microsoft Visual C++, create a new project and paste the following code:
    #include <activeds.h>
    
    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();
    }
    					
  2. 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.
  3. Link the project with the Activeds.lib and Adsiid.lib libraries.
  4. Set a breakpoint on the following line:
    hr=pIADsObject->PutEx()
    					

Modification Type:MinorLast Reviewed:3/4/2004
Keywords:kbbug kbMsg KB257999