WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get Exchange Server a Users Mailbox is On


Question:

Is there anyway to query what Exchange Server a User's Mailbox is on? I want to write a little script that the Helpdesk can use. They would enter the User's ID, and then it would display their Exchange Server.

Answer:

You could try checking the "msExchHomeServerName" property with the ADSI extender's GetProperty function. I am sure there are other ways, as well. You can get a user object using the dsFindPath function. Here is an untested example:
; Construct the full server ADSI path using serverless binding
sServerDn = dsGetProperty("LDAP://rootDSE", "serverName")
sServerName = ItemExtract(1, sServerDn, ",")
sServerName = ItemExtract(2, sServerName, "=")
sServerDn = dsGetProperty("LDAP://rootDSE", "defaultNamingContext")
sServerPath = "LDAP://%sServerName%/%sServerDN%"

; User's old style SAM account name.
sSamName   = "rtest"   ; As an example.

; Search for the user on the domain.
sUserPath = dsFindPath(sServerPath, "(&(objectCategory=person)(sAMAccountName=%sSamName%))")

sExchServer = dsGetProperty(sUserPath, "msExchHomeServerName" )

Article ID:   W16803
File Created: 2007:07:03:14:26:20
Last Updated: 2007:07:03:14:26:20