This code will modify the Phone number property of a mailbox. All users have access to modify this property on their mailbox by default.
This following code will cause the browser to pop up a user-identification dialog box. The IIS server's password authentication must be set to "Allow Anonymous" and "Basic (Clear Text)" only. This way, the browser will be able to use the correct security context when using the GetObject method.
Dim strAT ' Authorization Type information
strAT = Request.ServerVariables("AUTH_TYPE")
If InStr(1, "_BasicNTLM", strAT, 1) < 2 Then
Response.Buffer = True
Response.Status = ("401 Unauthorized")
Response.End
End If
Dim strMailboxPath ' ADsPath to the user's mailbox
Dim strServer ' name of the Exchange 5.5 server
Dim intPosPrefix ' numeric index used used to build ADsPath to
schema object
Dim intPosSuffix ' numeric index used used to build ADsPath to
schema object
Dim strPrefix ' prefix string used to build ADsPath to schema
object
Dim strSuffix ' suffix string used to build ADsPath to schema
object
Dim strPathToSchemaObject ' ADsPath to the schema object
Dim objMailbox ' mailbox object
Dim strNewPoneNumber ' value of the new phone number
Function isUserEditable(strSchemaObjectPath)
Dim objSchemaObject ' schema object
Dim intValue ' value of the Access-Category property
Set objSchemaObject = GetObject(strSchemaObjectPath)
intValue = objSchemaObject.Get("Access-Category")
If intValue = 2 Then ' user may modify the mailbox property
isUserEditable = True
Else ' the value was 0, 1, or 3
isUserEditable = False
End If
End Function
This procedure will modify the property of an object that contains a string value. To set a property to the empty string, you must remove it from the object:
Sub ModifyProperty(strNewValue, strADsProperty)
On Error Resume Next
If Len(strNewValue) <> 0 Then
objMailbox.Put strADsProperty, CStr(strNewValue)
Else ' The new value is empty
objIADs.Get (strADsProperty)
If the property doesn't exist on the object, an error will be generated using the Get method:
If Err.Number = 0 Then ' the property exists on the object and must be
removed
objMailbox.PutEx ADS_PROPERTY_CLEAR, strADsProperty, CStr(" ")
End If
Err.Clear
End If
End Sub
Const ADS_PROPERTY_CLEAR = 1 ' used by the PutEx method to clear a property
from an object
strPathToSchemaObject = strPrefix + "Telephone-Office1" + strSuffix
If isUserEditable(strPathToSchemaObject) Then
Set objMailbox = GetObject(strMailboxPath)
ModifyProperty strNewPoneNumber, "telephoneNumber"
objMailbox.SetInfo ' save the object information
Response.Write "Phone number modified successfully :)<BR>"
Else
Response.Write "You don't have permissions to modify your phone number
:(<BR>"
End If
%>
您可参看该提要:
Active Directory Services Interface in the Microsoft Exchange 5.5 Environment