I use the following custom ADSI functions (I think I posted them before when I 1st wrote them).
getEMail uses the current logged oon users account.
getEMail1 takes the NT account as a value.
'John Willis Sometime in 2000 ;-)
'ADSI Server-side functions (to be put in there own include when time allows or restructure takes place)
Function getEMail()
'John Willis 22-03-01
'This will get a users E-Mail address from the Wessex Exchange server and return it.
'If the user has no matching email in exchange then this will fail and just return nothing
'The (On Error Resume Next) is there to prevent an error code stoping the page if no email found.
On Error Resume Next
'ADSI User Object, Exchange Mailbox Server, NT logon
dim oUser, oMailbox, strNTLogon
strNTLogon = Request.ServerVariables("LOGON_USER")
strNTLogon = replace(strNTLogon, "\", "/")
strNTLogon = split(strNTLogon, "/")
'Actual E-mail address lookup code from Exchange Server
'LDAP String layout
'LDAP://[server]/cn=[username],cn=Recipients,ou=[organizational unit],o=[organization]
'LDAP String to Dev Exchange Server
'Set oMailbox = GetObject("LDAP://excdev1.********.com/cn=" & strNTLogon(1) & ",cn=Recipients,ou=DEV,o=Wessex Development")
'LDAP String to Live Exchange IIS Server
Set oMailbox = GetObject("LDAP://wxexciis002.********.com/cn=" & strNTLogon(1) & ",cn=Recipients,ou=WSX,o=Azurix")
'getEMail = oMailbox.Mail
'Braja Nayak - 26/11/2001. The following code is added to fix the bug faced by Simon Cole (Alasis not matching NT).
'To support the system for the time being.
If LCase(strNTLogon(1))="scole" Then
getEMail = "simon.cole@********.co.uk"
ElseIf LCase(strNTLogon(1))="szcole" Then
getEMail = "steve.cole@********.co.uk"
Else
getEMail = oMailbox.Mail
End If
End Function
Function getEMail1(strNTLogon)
'John Willis 23-03-01
'This will get a users E-Mail address from the Wessex Exchange server and return it.
'This version of the function requires an NTID to be passed to it (same as GetFullName1)
'and returns the email for that ID
'The (On Error Resume Next) is there to prevent an error code stoping the page if no email found.
On Error Resume Next
'ADSI User Object, Exchange Mailbox Server, NT logon
dim oUser, oMailbox
strNTLogon = replace(strNTLogon, "\", "/")
strNTLogon = split(strNTLogon, "/")
'Actual E-mail address lookup code from Exchange Server
'LDAP String to Live Exchange IIS Server
Set oMailbox = GetObject("LDAP://wxexciis002.********.com/cn=" & strNTLogon(1) & ",cn=Recipients,ou=WSX,o=Azurix")
getEMail1 = oMailbox.Mail
End Function
There is still a little bit of integration work to call them from the forum but it works fine for us (I'll dig out the integration code if needed as I moved to a SQL trigger some time ago on the live forum).
It does assume that your alias in Exchange 5.5 is the same as the matching NT account ID (A fudge around this is also shown).
I do have some code that used the NT account SID (Numeric GUID) to compare but that requires extra DLL's on top of ADSI to be installed on the server.
Apologies for the in house comments and examples. I just grabbed it from my include file and can’t be bothered to tidy it.