The following example demonstrates how to go about adding information about a user into a directory service in an ASP script. This example will demonstrate working with both single and multi-value attributes.
Example 1
The first example updates a user's attribute in the directory service specified by the default AUO entry. For this example, assume the schema definition for "objects" of type "member" has an attribute called "FavoriteColor." Assume further that the default AUO provider has the named value Class equal to "member" and the appropriate ADsPathPrefix named value contains a valid ADSI path prefix to a container "object" of objects of class "member." One could then proceed as follows:
<%
' Create the UserObjects object. We use the built-in Server "object"
' or dispinterface to create the object. This automatically
' innitializes the UserObjects object with the IIS server instance
' and the requesting user's username
Set IUserObjects = Server.CreateObject("Membership.UserObjects")
' set the target attribute name
Attribute1 = "FavoriteColors"
' Here we build an array of values to be put in a multivalue attribute
dim usArray
usArray = Array("blue","green","voilet","orange")
' define these ADSI related values here so they have "English"
' descriptions
const ADS_PROP_ERASE = 1
const ADS_PROP_UPDATE = 2
const ADS_PROP_APPEND = 3