Active Directory VBScript获取用户共享邮箱列表

时间:2013-08-13 00:28:22

标签: vbscript exchange-server

我在网上找到了一些脚本,但都是如此令人困惑,大约10页LOL ......

接下来是输入用户ID并搜索AD和后面的结果,如下所示:

姓名:Pavle Stoj 电子邮件:pavle.stoj @ ...

共享邮箱Pavle也可以访问:

  • mailbox 1
  • mailbox 2
  • mailbox 3

我可以获取姓名和电子邮件等,但是当我进入共享邮箱访问时,我不知道要运行的命令来获取它们吗?

到目前为止,我的例子对我来说很好..

' Check Exchange attributes for a 'user'
'
'
' -------------------------------------------------
' -------------------------------------------------

' Search box for userid
' ----------------------

strUsername = Inputbox ("UserID ?")
' -------------------------------------------------

' -------------------------------------------------
' Connect to AD and use the userid entered
' -------------------------------------------------

Set objRootDSE = GetObject("LDAP://RootDSE")
strDomain = objRootDSE.Get("DefaultNamingContext")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand = CreateObject("ADODB.Command")
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Searchscope") = 2
objCommand.CommandText = "SELECT distinguishedName FROM 'LDAP://" & strDomain & "' WHERE     objectCategory='User' AND samAccountName = '" & strUsername & "'"
Set objRecordSet = objCommand.Execute


' -------------------------------------------------
' Quick Check the user exists in AD
' ----------------------------------

If Not objRecordSet.EOF Then
    strDistOU = objRecordSet.Fields("distinguishedName").Value
Else
   MsgBox("No Results for: " & strUsername)
   Wscript.Quit
End If

' -------------------------------------------------

Set objUser = GetObject("LDAP://" & strDistOU)

strName = objUser.FullName

MsgBox strName

1 个答案:

答案 0 :(得分:0)

解决了......

delegateList = objUser.Get("publicDelegatesBL")

 For Each Desc In delegateList

  Set objMailbox = GetObject("LDAP://" & desc)
  WScript.Echo " " & objMailbox.DisplayName

 Next