Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: Authentication: NT
 Can user's email address be pulled from Exchange?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

BJH
Starting Member

16 Posts

Posted - 13 December 2002 :  16:59:29  Show Profile
hi all. i'm using NT auth and autologin on my company's intranet. is there a way to pull a domain user's email address from an exchange server? it would be great if i could auto-fill the user's email address in their profile.

cheers,
ben

David K
Junior Member

494 Posts

Posted - 14 December 2002 :  14:19:16  Show Profile  Send David K an AOL message  Send David K an ICQ Message  Send David K a Yahoo! Message
I belive it can't be done
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 14 December 2002 :  17:29:09  Show Profile
Do a search in the NT authentication forum. I think someone has done it. You will need to use ADSI functions to do it.

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page

Kal Corp
Average Member

USA
878 Posts

Posted - 23 December 2002 :  10:27:06  Show Profile  Visit Kal Corp's Homepage


I have this working, it was not easy thing.

In my environment, I had to set my LDAP.asp file to use a account that could access the exchange server to get the data. the Web server could not do it.

My forum calls a LDAP.asp file then it saves that info to the session and then it comes back to the forums the then I can read the sessions info and save it.
Only way I could get it to work.

This was my ldap.asp file. remember that the file setting had to be change to use account i set up to access the exchange. you might not need that. so this code could be placed in the main code like normal.

<!--#INCLUDE FILE="config.asp" -->
<!--#INCLUDE FILE="inc_func_common.asp" -->
<%

dim oCn
dim oRS
dim sUser
dim rsRecipients


set oCn = Server.CreateObject("ADODB.Connection")
set oRS = Server.CreateObject("ADODB.Recordset")
sUser = Session(strCookieURL & "userID")
if instr(1,sUser,"\") <> 0 then
sUser = mid(sUser, instr(1,sUser,"\")+1)
end if

on error resume next
set oCn = server.CreateObject("ADODB.Connection")
oCn.Provider = "ADsDSOObject"
oCn.Open "Active Directory Provider"
if err.number <> 0 then
Session("Status") = "Error: " & err.number & " - " & err.description
RESPONSE.WRITE ("ERROR on object" )
else

Set oCom = CreateObject("ADODB.Command")
oCom.ActiveConnection = oCn
strExchangeServer = "LDAP://XXXX.com/o=XX"
strQuery = "<" & strExchangeServer & ">;(&(uid=" & sUser & "));sn,cn,mail,department,telephonenumber,uid"

oCom.CommandText = strQuery
Set rsRecipients = oCom.Execute
if err.number <> 0 then
Session("Status") = "Error: " & err.number & " - " & err.description &" ---- strQuery=" & strQuery
RESPONSE.WRITE (" Error On Query: " & Session("Status") & "<BR>")
end if

if rsRecipients.RecordCount > 0 then
for each oF in rsRecipients.Fields
session(oF.Name) = oF.Value
'##RESPONSE.WRITE ("ID = " & oF.name &" |")
'##RESPONSE.WRITE (" NAME:" & session(oF.Name) & " <BR>" )


next
else
Session("Exchange") = "None"
end if
end if


Session(strCookieURL & "strNTUsercn")=session("cn")
Session(strCookieURL & "strNTUserEmail")=session("Mail")
Session(strCookieURL & "strNTUserdepartment")=session("department")
Session(strCookieURL & "strNTUsertelephonenumber")=session("telephonenumber")
Session(strCookieURL & "GotLDAP")="YES"
%>
<!--#INCLUDE FILE="inc_footer.asp" -->
<%
'## Response.redirect(Session(strCookieURL & "StartPath"))
Response.redirect("pop_profile.asp?mode=goEdit§ionid=7")
%>





{VAS}-Kal Corp
VAS Development NetWork - Forums for old Snitz Mods!
Creator of all things {VAS}
Go to Top of Page

DJWillis
Starting Member

United Kingdom
39 Posts

Posted - 09 January 2003 :  07:33:17  Show Profile  Send DJWillis an ICQ Message
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.

Regards

John Willis

"You can have any error screen, as long a it's blue"
Go to Top of Page

twin
New Member

78 Posts

Posted - 16 January 2003 :  11:28:21  Show Profile
Hello Djwillis,

can you please tell me how and where to integrate your code ?

And you have some commented lines in there. Which lines must i uncomment to get it run on my Win2000/IIS5/Exchange5.5/NT-Auth-Environment ?

Thank you in advance

Best Regards

twin
Go to Top of Page

twin
New Member

78 Posts

Posted - 16 January 2003 :  11:31:09  Show Profile
Forgotten:

Maybe there is a little step by step guide ?
This would be great for us "Exchange-Users" :-)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.15 seconds. Powered By: Snitz Forums 2000 Version 3.4.07