Updating Member Properties Using ADSI May Cause Corruption

ID: Q231732


The information in this article applies to:
  • Microsoft Site Server version 3.0


SYMPTOMS

When you use ADSI to programmatically change member properties in a Site Server Membership database, some of the properties may become corrupt. Note that this only occurs when you attempt to set one or more properties to a null value, which is not normally possible through the Site Server Administration interface.


CAUSE

This problem occurs when you update multiple properties before the call to SetInfo and you set one or more of these properties to a null string. This is caused by a problem in Site Server Membership.

The following VBScript sample code demonstrates the problem. This example assumes there is a Membership database called TestMembership, and that the anonymous user has rights to create and modify members.


On Error Resume Next
server = "yourservername" ' the name of your site server machine
Port = ":1003" ' the port the membership is configured on
membershipname = "TestMembership"
nameofmembercontainer = "Members" ' for a newly created membership this will usually be Members

membercontainerpath = "LDAP://" & server & Port & "/ou=" & nameofmembercontainer & ",o=" & membershipname
Set membercontainer = GetObject(membercontainerpath)
Set member = membercontainer.Create("member", "cn=JohnDoe")
member.Put "GUID", "0123456789" 'this is not a real GUID and should be used only for this test
member.Put "mail", "myaddress@myhouse"
member.Put "givenName", "John"
member.Put "sn", "Doe"
member.Put "c", "United States"
member.SetInfo

If Err <> 0 Then
    MsgBox "Error number " & Hex(Err)
Else
    MsgBox "New member successfully added"
End If




' get the latest values from the server rather than the cache
member.GetInfo
' show properties
MsgBox "mail=" & member.Get("mail")
MsgBox "c=" & member.Get("c")
MsgBox "givenName=" & member.Get("givenName")
MsgBox "sn=" & member.Get("sn")


' make changes
member.Put "mail", "" ' note we are specifying a null length string here
member.Put "givenName", "Jane"
member.Put "sn", "Doe"
member.SetInfo
MsgBox "Changes complete. About to display all properties again"


' get the latest values from the server rather than the cache
member.GetInfo
' show properties again
MsgBox "mail=" & member.Get("mail")
MsgBox "c=" & member.Get("c")
MsgBox "givenName=" & member.Get("givenName")
MsgBox "sn=" & member.Get("sn")

MsgBox "About to delete member"
membercontainer.Delete "member", "cn=JohnDoe"
MsgBox "Member deleted"
 
To run the above script, if you have the Windows Scripting Host installed, put the script in a file with a .vbs extension and double-click it. Alternatively, you can adapt the code to run as an ASP script in a Web page (note that you will need to remove the MsgBox functions).

When you run this code, a new member is created and some properties are set. The values of these properties are then displayed in message boxes as confirmation. Some updates are then made to these properties, including an update to the e-mail address, setting it to a null string. The properties of the member are then displayed again. This time, you should see that the givenName property is now something like ¬?ne. The details of the corruption may vary.


WORKAROUND

To work around this problem, call SetInfo after each PUT command, as in the following example:


member.Put "mail", "" ' note we are specifying a null length string here
member.SetInfo
member.Put "givenName", "Jane"<BR/>
member.SetInfo
member.Put "sn", "Doe"<BR/>
member.SetInfo 


STATUS

Microsoft has confirmed this to be a problem in Microsoft Site Server version 3.0.

Additional query words: setinfo corrupt property

Keywords :
Version : winnt:3.0
Platform : winnt
Issue type : kbbug


Last Reviewed: October 27, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.