We help IT Professionals succeed at work.

NT-LOGON with ASP

Morrow1
Morrow1 asked
on
I am working on an INTRANET site.

The Environment we have is:
NT 4.0
IIS 5.0
SQL 7.0

I have a table "USERS" in the database with field "LoginName" which is same as the User-Logins on the Network.

I want to capture the User-Logon of the User that he is provided on the Network, when he visits this INTRANET site. BECASUE then i will compare that to the field in the table I have "USERS". And based upon -

*If his LOGON matches the "LoginName" in the table, he will get to see different content based upon the rules.


HOW WOULD I DO THAT ?

IN other words when I log on my network my Username is "WEBUSER". I have this record in the database for this INTRANET Site. Once I am authenticated thru NT on my machine I can log on to this site. I need a script /way/method to capture this "WEBUSER" Logon-Name in my ASP page to program further.

Please Help
Comment
Watch Question

Commented:
login_name= Request.ServerVariables("LOGON_USER")
I Also have the same problem but i have seen it ork on snitz forum
source code of which is available at snitz.com
but i didnt have luck in finding that code.

Author

Commented:
prokni...

i tried this, it doesnt work at all..

Tell me something if u have used it urself .... cuz then I can begin to look into it

Commented:
I used this one by myself,
Do you let them to connect as anonymous?
Commented:
Thsi is the source that i wrote to do teh same thing.
I ahve the sma efield in table that ahs user login information. I get employees'supervisor id from the table base who they are.
Make sure you have the right security on your IIS setting, remove teh anonymous login and if you want to netscape user be able to do the same thing, check the basic Authentication as well.
************************************
login_name= Ucase(Request.ServerVariables("LOGON_USER"))

     Set CMD = Server.CreateObject( "ADODB.Command" )
          CMD.ActiveConnection = Con
          CMD.CommandType = adCMDStoredProc        
          CMD.CommandText = "OR_DB_INTFC.getempinf_from_loginname"
     
     CMD.Parameters.Append CMD.CreateParameter("i_login_name",AdVarchar, adParamInput,50,login_name)
          CMD.Parameters.Append CMD.CreateParameter("o_employeeno",adNumeric, adParamoutput)    
          CMD.Parameters.Append CMD.CreateParameter("o_fname",AdVarchar, adParamoutput,1000)    
          CMD.Parameters.Append CMD.CreateParameter("o_lname",AdVarchar, adParamoutput,1000)    
          CMD.Parameters.Append CMD.CreateParameter("o_errmsg",AdVarchar, adParamoutput,1000)    
     
          CMD.Execute
     
          errmsg=     CMD.Parameters("o_errmsg").value
          employeeno  =     CMD.Parameters("o_employeeno").value              
          session("Session_started") = 1
          session("supervsren") = employeeno
          target = "default.asp"                         CMD.ActiveConnection = Nothing
          SET CMD = Nothing              
Hi prokni
how can i find the nt loginname description

Commented:
I am not sure,
But I think it is better to go with ADSI for that.
Set myObj = GetObject("WinNT://" & Domain)
myobj.Filter = Array("user")
For Each user In myobj
    response.write "<br><b>User</b>:" & user.Name
    response.write ", <b>Parent is</b> : " & user.Parent
      response.write ", <b>AccountDisabled is</b> : " & user.AccountDisabled
Next

I am not sure if you can get user description with WinNT provider, you definitly can do it with LDAP provider on active directory.

Author

Commented:
BINGO prokni... Its working !!

I was unaware of the fact that I had the AnonymousLogin Enabled along with NT enable on my machine. I set the Anonymous to false and now I am able to trap the login name.

I guess thats a good sign.
One more question if you want to answer.

How long do you think the User will be recognized by the IIS thru this NT Authentication as i am Supposed to TURN OFF the Session too. Or does it stay untill the Browser is open.

I am going to accept ur answer anyways

Author

Commented:
Thanks for the Answer with description of the Security settings. It works and now I am able to trap the user login and play with it...

Author

Commented:
BINGO prokni... Its working !!

I was unaware of the fact that I had the AnonymousLogin Enabled along with NT enable on my machine. I set the Anonymous to false and now I am able to trap the login name.

I guess thats a good sign.
One more question if you want to answer.

How long do you think the User will be recognized by the IIS thru this NT Authentication as i am Supposed to TURN OFF the Session too. Or does it stay untill the Browser is open.

I am going to accept ur answer anyways

Commented:
Actually I would keep the session timeout the same, What i am doing in my case, I check the session in the beginning of each page and if my session is empty then I forward them to the same page that they loged in, still it gets the Request.ServerVariables("LOGON_USER")).
    This one has nothing to do with session time out and still it gets the same login name information and starts all over again but it depends totally to your situation.

good luck

Author

Commented:
Thanks. It all works well........

Explore More ContentExplore courses, solutions, and other research materials related to this topic.