求救,关于exahnge5.5的操作!!高分相送!!!!

johnchou2002 2002-07-22 10:36:41
各位高手:

可否通过VB对通过ADSI 或者CDO 对 exchange5.5 进行操作,自动添加或者删除用户的邮箱,或者是修改用户邮箱的属性,例如:first name,last name,business call , fax等等。如有可能,最好给出实例说明性的源代码。

高分相送。

提前谢过!!

...全文
48 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ruidong 2002-07-24
  • 打赏
  • 举报
回复
感谢您使用微软产品。



1. CDO 1.21 的例子, 修改地址中department的讯息。



On Error Resume Next
Set myse = CreateObject("mapi.session")
myse.Logon , "", False, True, , , "ruidongexchange" & vbLf & "administrator"

Set myadd = myse.AddressLists(1).AddressEntries(1)


myadd.Fields(974651422).Value = "fighting club"

'974651422 is &H3A18001E.

myadd.Update



Set myadd = Nothing
Set myse = Nothing



更多的CDO properties index, 您可以从该链接获得。

http://www.outlookexchange.com/Articles/home/cdopropertytagconstants.asp



2. ADSI 的例子。



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

strMailboxPath = "LDAP://SPARKER1/cn=SParker,cn=Recipients,ou=3081,o=16"
strServer = "sparker1"
strNewPoneNumber = "(425) 882-8080 x 13882"

intPosPrefix = InStr(strMailboxPath, "/cn")
intPosSuffix = InStr(strMailboxPath, "ou")
strPrefix = Mid(strMailboxPath, 1, intPosPrefix - 1) + "/cn="
strSuffix = ",cn=Microsoft DMD," + Mid(strMailboxPath, intPosSuffix,
Len(strMailboxPath))

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

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnactdir/html/msdn_adsiexch.asp



一般来说,修改Exchange 5.5 的全局通讯录,用ADSI更好些,Outlook个人通讯录,使用CDO。




希望这些讯息对您有帮助。



- 微软全球技术中心 DTA技术支持



本贴子仅供CSDN的用户作为参考信息使用。其内容不具备任何法律保障。您需要考虑到并承担使用此信息可能带来的风险。具体事项可参见使用条款 (http://www.csdn.net/microsoft/terms.shtm)。

Oracle_Ran 2002-07-22
  • 打赏
  • 举报
回复
我也很想知道,大家来说说呀

535

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 Exchange Server
社区管理员
  • 消息协作社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧