Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Finding a users exchange server

Keywords:   Finding a user's exchange server

Question:

Is there any way that WinBatch can find which exchange server a user's mailbox is located by using the user login ID? I know it can be done because when you configure Outlook for Microsoft Exchange Server, you can put the user's name and then click on "Check Name" and it displays the exchange server the user's mailbox is located on. I've figured a way to find this in the registry (under Current User) but if a user is migrated to windows 2000, I want a script to be able to verify where a user's mailbox is located.

Thanks for any tips

Answer:

See Microsoft KB Article ID: Q183917 titled "HOWTO: Find a User's Home Exchange Server from a MAPI Session". The property "HOME-MTA" is the user's home Exchange Server.

And here's some sample code:

AddExtender("WWADS34I.DLL")
AddExtender("WWWNT34i.DLL")

PDCD = AskLine ("Domain","Enter The Domain (Usually IWS).","IWS")
PDC = wntGetDc ("",PDCD,1)

:ExchLoop
ExAdsiPath = AskLine("Exchange Server", "Enter the Exchange Server for the LDAP search", "ehud08")
ExchCheck = wntServerInfo(ExAdsiPath, 1)
If LastError() == 524
Display (4,"Exchange Server access error", "Cannot Access %ExAdsiPath%%@CRLF%Please select
another Exchange Server")
gosub ExchLoop
endif

sAdsiPath = "LDAP://%ExAdsiPath%/o=ml"
;** Normally use the line UserName = wntUserInfo(0) for when a use logs on
Username = "malbrjo" 
userSID = wntAcctInfo( pdc, username, 1) 
aAdsiPath = DsFindPath(sAdsiPath, "Assoc-NT-Account=%userSID%")
errormode (@Off)
HomeExchangeA = dsGetProperty(aAdsiPath, "Home-MTA")
HomeExchangeB = StrScan(HomeExchangeA, ",", 20, @FWDSCAN)

HomeExchangeServer = strSub (HomeExchangeA,21,HomeExchangeB - 21) 
message (Username,HomeExchangeServer)

Article ID:   W15043