Author |
Topic |
|
sumo
Junior Member
USA
121 Posts |
Posted - 21 March 2001 : 00:59:52
|
Title: MS Exchange E-mail Retrieval Version: 1.00
Installation: Add or change code in red Demo: No demo available Support: Please post questions in the Help: MOD Implementation forum
Features:
- Retrieve an NT domain user's e-mail address from MS Exchange Server and automatically save it in user's profile
Restrictions:
- Only works with NT Auto-Login set
Notes:
- If you'd like to change this MOD to work with any type of NT login, feel free.
- Port 389 must be open for TCP communications if your Exchange Server is behind a firewall where the forum web server may not be able to access. That port must be opened to allow LDAP communication.
..--== STEP 1 ==--.. FILE: inc_functions.asp MODS: IN RED FUNC: NTAuthenticate() LINE: Approx. 1228
'Multi-domain NT authentication MOD sub NTAuthenticate() dim strUser, strNTUser, checkNT, strNTUserEmail dim oMailbox 'Exchange Mailbox dim aUser
strNTUser = Request.ServerVariables("AUTH_USER") strNTUser2 = replace(strNTUser, "\", "/") aUser = split(strNTUser2, "/")
if Session(strCookieURL & "userid") = "" then strUser = strNTUser Session(strCookieURL & "userid") = strUser end if
if strNTGroups="1" then strNTGroupsSTR = Session(strCookieURL & "strNTGroupsSTR") if Session(strCookieURL & "strNTGroupsSTR") = "" then Set strNTUserInfo = GetObject("WinNT://"+strNTUser2) For Each strNTUserInfoGroup in strNTUserInfo.Groups strNTGroupsSTR=strNTGroupsSTR+", "+strNTUserInfoGroup.name NEXT Session(strCookieURL & "strNTGroupsSTR") = strNTGroupsSTR end if end if if strAutoLogon="1" then strNTUserFullName = Session(strCookieURL & "strNTUserFullName") if Session(strCookieURL & "strNTUserFullName") = "" then Set strNTUserInfo = GetObject("WinNT://"+strNTUser2) strNTUserFullName=strNTUserInfo.FullName Session(strCookieURL & "strNTUserFullName") = strNTUserFullName 'E-mail address retrieval from Exchange Server 'LDAP://[server]/cn=[username],cn=Recipients,ou=[organizational unit],o=[organization] Set oMailbox = GetObject("LDAP://kawexc/cn=" & aUser(1) & ",cn=Recipients,ou=Keystone,o=Keystone Automotive") strNTUserEmail = oMailbox.Mail Session(strCookieURL & "strNTUserEmail") = strNTUserEmail end if end if end sub
..--== STEP 2 ==--.. FILE: register.asp MODS: IN RED LINE: Approx. 202
Find this:
strSql = strSql & ", " & "'" & ChkString(Request.Form("Email"),"email") & "'"
Replace with this:
If strAutoLogon = "1" then strSql = strSql & ", " & "'" & Session(strCookieURL & "strNTUserEmail") & "'" Else strSql = strSql & ", " & "'" & ChkString(Request.Form("Email"),"email") & "'" end if
If you have any questions, please post them here or feel free to e-mail me!
Mike http://www.sumovw.com/ http://www.sumovw.com/forum/ http://www.sumofx.com/
Edited by - sumo on 22 March 2001 20:39:49 |
|
Kal Corp
Average Member
USA
878 Posts |
Posted - 04 April 2001 : 22:04:44
|
Anyone else using this?
|
|
|
sumo
Junior Member
USA
121 Posts |
Posted - 06 April 2001 : 00:41:07
|
There might be one other that I got e-mail from. There are some inherent problems with my coding on this one, the biggest one being properly extracting the username. If I had time, I would see how to make this work in all situations and even add an admin feature to type in an IP address or computer name, organization, organizational unit, etc. for the LDAP statement.
Realistically, NT Auto-Login shouldn't be necessary... just NT authentication, since the username is really the only thing that can be used to match up an e-mail box on an Exchange Server with.
quote:
Anyone else using this?
Mike http://www.sumovw.com/ http://www.sumovw.com/forum/ http://www.sumofx.com/ |
|
|
DJWillis
Starting Member
United Kingdom
39 Posts |
Posted - 06 April 2001 : 04:58:56
|
There is a few small inherent problems with this :(.
Try using this script with a user who does not have an associated Exchange account (a not unknown occurrence) and watch it fall over. I have a half-baked solution to this that requires you adding
'The (On Error Resume Next) is there to prevent an error code stopping the page if no email found.
On Error Resume Next
To the top of the Sub to get it to return nothing (rather then a Script error), you will need to then add some conditional code to check if you got an e-mail or not.
The other bug bear is that it requires your Exchange short common name to equal your NT logon, not all company’s and exchange admins do this, and there is no guarantee this will work 100% of the time even if your Exchange CN is the same as you NT account as there are normally exceptions for whatever reason. There are about 15 exceptions in our 2000 user Exchange/NT setup.
Eg,..
User JWILLIS on NT = User DJWILLIS on Exchange. So the code returns an error or no e-mail address as user JWILLIS was not found on Exchange.
I have a (mostly working) solution (using very similar base code) but it relies on registering DLL's (ADSecurity.DLL) from the ADSI SDK to work as it compares the unique ID (serial number of an NT account) with the unique ID of an exchange account and returns no value if none found or the e-mail if it is found. This should work even in the example above (basically, if outlook can get there e-mail from there NT account, so can this code).
That said the code is a really nice example of how to use LDAP. Most of this is just nit picking.
Regards
John Willis
"You can have any error screen, as long a it's blue" |
|
|
sumo
Junior Member
USA
121 Posts |
Posted - 06 April 2001 : 08:26:07
|
quote:
Try using this script with a user who does not have an associated Exchange account (a not unknown occurrence) and watch it fall over. I have a half-baked solution to this that requires you adding
'The (On Error Resume Next) is there to prevent an error code stopping the page if no email found.
On Error Resume Next
To the top of the Sub to get it to return nothing (rather then a Script error), you will need to then add some conditional code to check if you got an e-mail or not.
Yeah, this I know. I've been planning on looking at the code again to make it foolproof...
quote:
The other bug bear is that it requires your Exchange short common name to equal your NT logon, not all company’s and exchange admins do this, and there is no guarantee this will work 100% of the time even if your Exchange CN is the same as you NT account as there are normally exceptions for whatever reason. There are about 15 exceptions in our 2000 user Exchange/NT setup.
Eg,..
User JWILLIS on NT = User DJWILLIS on Exchange. So the code returns an error or no e-mail address as user JWILLIS was not found on Exchange.
I have a (mostly working) solution (using very similar base code) but it relies on registering DLL's (ADSecurity.DLL) from the ADSI SDK to work as it compares the unique ID (serial number of an NT account) with the unique ID of an exchange account and returns no value if none found or the e-mail if it is found. This should work even in the example above (basically, if outlook can get there e-mail from there NT account, so can this code).
I'd love to add this capability into the mod and provide instructions. Willing to share?
quote:
That said the code is a really nice example of how to use LDAP. Most of this is just nit picking.
I don't think you're nitpicking. If someone doesn't review my work, I'll think that it's perfect. There's always room for improvement, handling of situations I never thought of... two brains are better than one.
Mike http://www.sumovw.com/ http://www.sumovw.com/forum/ http://www.sumofx.com/ |
|
|
DJWillis
Starting Member
United Kingdom
39 Posts |
Posted - 06 April 2001 : 10:15:10
|
quote:
I'd love to add this capability into the mod and provide instructions. Willing to share?
No problem, current issues are that this is built into a large scale ADSI Control system for out Intranet that I built a while back and I need to pull it out and into Snitz rather then the bodged patch we currently use. I will have a go at tidying this up over the next week or so and try and get some code out for discussion (with your help). There is a thread in the NT Forum about this I started ages ago but work got very busy etc. etc :), you know the score.
Regards
John Willis
"You can have any error screen, as long a it's blue"
Edited by - djwillis on 06 April 2001 10:17:32 |
|
|
sumo
Junior Member
USA
121 Posts |
Posted - 06 April 2001 : 14:46:26
|
I just went through and revamped most of my code. I added an admin feature where you can choose to turn on or off Exchange Server support. Then, I added fields to save the exchange server address, container, organizational unit, and organization variables used in the LDAP statement.
I also added in some checks of the cookie AND the database to make sure there isn't already an e-mail address there. This speeds things up, since I should only be grabbing the e-mail address from the Exchange server when there is no address at all (meaning new user registration).
And, lastly, I added "On Error Resume Next" right before it tries to retrieve the e-mail address from the server.
Of course, the last thing I need to do is create the database setup file to be used with mod_dbsetup.asp, since there are, I believe 5 new fields that need to be added to the FORUM_CONFIG table.
I will, of course, post the MOD when it is complete. This will be version 2.0, btw.
Mike http://www.sumovw.com/ http://www.sumovw.com/forum/ http://www.sumofx.com/ |
|
|
Kal Corp
Average Member
USA
878 Posts |
Posted - 01 May 2001 : 13:08:10
|
Got Code?
|
|
|
Greg Bowman
Starting Member
USA
30 Posts |
Posted - 15 June 2001 : 16:25:23
|
Hi
just wanted to check if any code was released. I could really benefit from getting the Exchange email address.
thx GReg
|
|
|
sumo
Junior Member
USA
121 Posts |
|
Kal Corp
Average Member
USA
878 Posts |
Posted - 11 July 2001 : 10:42:02
|
Bump
Any thing on this?
|
|
|
sumo
Junior Member
USA
121 Posts |
Posted - 11 July 2001 : 10:44:26
|
It's nice to see you're still checking in on this. As of yet, nothing. Our project that involved the Snitz forum got shelved for the time being, so I have not worked on any of this code for quite a while. I have not forgotten about it, though.
quote:
Bump
Any thing on this?
Mike http://www.sumovw.com/ http://www.sumovw.com/forum/ http://www.sumofx.com/ |
|
|
DJWillis
Starting Member
United Kingdom
39 Posts |
Posted - 11 July 2001 : 11:33:08
|
quote:
It's nice to see you're still checking in on this. As of yet, nothing. Our project that involved the Snitz forum got shelved for the time being, so I have not worked on any of this code for quite a while. I have not forgotten about it, though.
Same here, from the bit of the code I was going to do, however I recon that are Snitz project will pick up speed soon so I hope to get some code out soon.
Regards
John Willis
"You can have any error screen, as long a it's blue" |
|
|
Kal Corp
Average Member
USA
878 Posts |
Posted - 26 July 2001 : 20:06:28
|
Bump
|
|
|
madfiddler
Starting Member
United Kingdom
33 Posts |
Posted - 13 August 2001 : 08:09:33
|
quote:
The other bug bear is that it requires your Exchange short common name to equal your NT logon, not all company’s and exchange admins do this, and there is no guarantee this will work 100% of the time even if your Exchange CN is the same as you NT account as there are normally exceptions for whatever reason. There are about 15 exceptions in our 2000 user Exchange/NT setup.
Eg,..
User JWILLIS on NT = User DJWILLIS on Exchange. So the code returns an error or no e-mail address as user JWILLIS was not found on Exchange.
quote:
I have a (mostly working) solution (using very similar base code) but it relies on registering DLL's (ADSecurity.DLL) from the ADSI SDK to work as it compares the unique ID (serial number of an NT account) with the unique ID of an exchange account and returns no value if none found or the e-mail if it is found. This should work even in the example above (basically, if outlook can get there e-mail from there NT account, so can this code).
Even if there is no code available yet could someone explain how this is done please? it would really solve a lot of headaches for me!!!
cheers
|
|
|
|
Topic |
|