我在网上找到了一些脚本,但都非常混乱,大约 10 页长 LOL...
我之后是输入用户 ID 并搜索 AD,我之后的结果类似于:
姓名:Pavle Stoj 电子邮件:pavle.stoj@...
共享邮箱 Pavle 也可以访问:
- 邮箱 1
- 邮箱 2
- 邮箱 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