Unexpected behavior may occur when you use the System.DirectoryServices namespace with the .NET Framework 1.1 SP1 and the .NET Framework 1.0 SP3 (886541)



The information in this article applies to:

  • Microsoft Windows Server 2003, Datacenter Edition
  • Microsoft Windows Server 2003, Enterprise Edition
  • Microsoft Windows Server 2003, Standard Edition
  • Microsoft Windows Server 2003, Web Edition
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows 2000 Datacenter Server
  • Microsoft Windows 2000 Professional
  • Microsoft Windows 2000 Server
  • Microsoft Windows XP 64-Bit Edition
  • Microsoft Windows XP Professional
  • Microsoft .NET Framework 1.0

SYMPTOMS

If you have installed the Microsoft .NET Framework 1.1 Service Pack 1 (SP1) or the .NET Framework 1.0 Service Pack 3 (SP3), you may receive error messages or experience unexpected behavior when you use the System.DirectoryServices namespace. These errors may occur when you perform different types of operations on PropertyValueCollection class can generate these errors. For example, you may receive one of the following error messages:
Error message 1
Operation is not valid due to the current state of the object.
Error message 2
An unhandled exception of type System.InvalidOperationException' occurred in mscorlib.dll.
Error message 3
80004005 - Unknown Error
Error message 3 occurs when the credentials in a DirectoryEntry are authenticated, typically on a RefreshCache operation. For example:
DirectoryEntry de = new DirectoryEntry(sLDAP, sUsername, sPassword, AuthenticationTypes.Secure);de.RefreshCache();
Error message 4
Not Implemented
You may recieve error message 4 during a bind operation. Notice that the bind connection will not occur until an operation is performed. If a RefreshCache method operation is not performed, the failure may occur later in the code. For example, the failure may occur during a FindAll method operation.
DirectoryEntry de = new DirectoryEntry(strLDAP);
//  Bind not performed yet
DirectorySearcher mySearcher = new DirectorySearcher(de);
//the bind has not occured yet - but will happen when the next line executes
//  this line could generate the error Not Implemented
SearchResultCollection result = mySearcher.FindAll();

RESOLUTION

To resolve this problem, you must apply hotfix 835763. Hotfix 835763 is a prerequisite for the .NET Framework 1.1 SP1 and the .NET Framework 1.0 SP3. This hotfix is part of Microsoft Windows XP Service Pack 2 (SP2) and Microsoft Windows Server 2003 Service Pack 1 (SP1). Earlier versions of these operating systems require this hotfix. For example, Microsoft Windows 2000 Service Pack 4 (SP4), Windows Server 2003, and Windows XP SP1 require this hotfix.

The classes in the System.DirectoryServices namespace wrap ADSI functionality. The System.DirectoryServices namespace needs the new functionality to exist in the underlying ADSI technology that hotfix 835763 provides. For more information, click the following article number to view the article in the Microsoft Knowledge Base:

835763 IADs::Put/PutEx or IADsPropertyList::PutPropertyItem calls may not accumulate

Because hotfix 835763 updates the underlying ADSI objects, you can install this hotfix either before or after you install the .NET Framework 1.0 SP3 or the .NET Framework 1.1 SP1.

MORE INFORMATION

You can perform multiple Add operations without generating an error. For example, the following code does not generate an error:
De.Properties["phonenumber"].Add("111");
De.Properties["phonenumber"].Add("222");
However, if you perform different operations, an error is generated. The following example tries to perform an Add operation that is followed by a Remove operation. The following code generates an error:
De.Properties["phonenumber"].Add("111");
De.Properties["phonenumber"].Remove("222");
If you perform operations that use an index, an error is generated. For example, the following code generates an error:
De.Properties["phonenumber"][0] = "111-222";

REFERENCES

For more information about the way that the System.DirectoryServices namespace is layered on ADSI, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:6/13/2005
Keywords:kbprb KB886541 kbAudDeveloper