OutFront Forums
     Home    Register     Search      Help      Login    

Follow Us
On Facebook
On Twitter
RSS
Via Email

Recent Posts
Todays Posts
Most Active posts
Posts since last visit
My Recent Posts
Mark posts read

Sponsors
Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.
Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.
Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

 

NT authentication

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP, PHP, and Database >> NT authentication
Page: [1] 2   next >   >>
 
BeTheBall

 

Posts: 6487
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
NT authentication - 3/10/2003 15:16:56   
I have a db table that contains a list of all employees. I want to display certain field from that table on a webpage. If I add each employee' s NT Login to the DB, can I then format my page so that it will recognize the employee when he/she opens the page and display his/her data???
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: NT authentication - 3/10/2003 20:14:19   
Possibly - the web will need to be Authenticated (ie - not allow anonymous)
(tools > permissions)
However, I think it is necessary to have each user you want allowed, access to the web via the permissions tab. (otherwise they wont get in!)

On our intranet, we do this via a group user account which allows all employees access. If your administrator hasnt got a group set up, I fear you may have to add individuals.

Once set up, youll gain access to the code :
<%=request.servervariables(" LOGON_USER" )%> which will return the raw account name. (Possibly DOMAIN/USER)
This can be used to compare with your database entry.

I hook into a HR system on SQL server which gives all of the details for that particular user (all based on the NT login for their PC)

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to BeTheBall)
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: NT authentication - 3/10/2003 20:18:33   
BTW - Funny story :-)
Every time I look at your avatar, I have visions of an incident that happened at work. An employee, (not too dissimilar to the photo) was working alone one night, checking his email as you do, when he decided to print off a slightly naughty picture he had received.
Clicking send to printer, meant it was diverted to a shared printer.

However, as it was late, the office that had the printer was locked.
I can still see his face pressed to the door glass now going " DOH!"
He was collared quite quickly in the morning......

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to BeTheBall)
BeTheBall

 

Posts: 6487
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: NT authentication - 3/11/2003 18:21:43   
Thanks for the help Spooky. I think most of the things you suggest are already done. The web where I am going to use this is already a NT authenticated web with no anonymous access. Also, I believe our IT people have granted access to all domain users. Is there a small piece of code that I could paste on a page and then view in my browser to see if it returns my NT login info? This would let me know if I am ready to go.

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to BeTheBall)
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: NT authentication - 3/11/2003 19:28:04   
Sure, just a simple asp page like :

<%=request.servervariables(" LOGON_USER" )%>


_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to BeTheBall)
BeTheBall

 

Posts: 6487
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: NT authentication - 3/12/2003 11:17:56   
Hey, works great! It returns Domain\Username. Is there any way to parse out the domain\ out of the results? My database contains the username only and I really don' t want to append the domain\ to every record.

Also, how would I write my SQL? Select * from table WHERE login = ?????

< Message edited by betheball -- 3/12/2003 11:27 AM >

(in reply to BeTheBall)
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: NT authentication - 3/12/2003 12:20:29   
Select * from table WHERE login =' " &Replace(request.servervariables(" LOGON_USER" ), " domain\" ," " )&" ' " 


_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to BeTheBall)
BeTheBall

 

Posts: 6487
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: NT authentication - 3/12/2003 13:52:54   
Spooky, I am losing my mind. Before my last post I created a page called test.asp. In between the <body> tags I pasted:

<%=request.servervariables(" LOGON_USER" )%>


I then saved the page and viewed it in my brower. Sure enough, I see
OSC\ddthom29, my domain\login ID. I then messed with a few things, went back to the page and it now won' t show anything. The page comes back blank. Any ideas what may have happened. I even tried creating a new page with only the above code in the body and nothing???

< Message edited by betheball -- 3/12/2003 1:54 PM >

(in reply to BeTheBall)
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: NT authentication - 3/12/2003 22:07:43   
Perhaps someone made the web anonymous?
If this code just shows : User = , then I guess thats the cause :)


User = <%=request.servervariables(" LOGON_USER" )%>


_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to BeTheBall)
BeTheBall

 

Posts: 6487
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: NT authentication - 3/13/2003 8:34:40   
Thanks again Spooky. We had deleted the anonymous user account from the list of authorized users, but I didn' t realize that the anonymous user was also part of the EVERYONE group. I do find it odd that the page worked momentarily because IT rarely messes with the server and they would have had to have done something minutes after I first tested the page because it worked, then 5 minutes later, it didn' t. Oh well, I found a NT group that all of my intended users belong to, so I added it and deleted the Everyone group from the list.

(in reply to BeTheBall)
BeTheBall

 

Posts: 6487
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: NT authentication - 3/13/2003 14:01:17   
OK Spooky (or anyone else), one more question. If I wanted to simply display " Hello (Login)" , how would I do it. In other words, similar to what you showed me in the SQL, how would I parse out the domain\ to simply display the login name in the body of my page.

I am sure it is becoming increasingly obvious how little I know about coding, but these questions help me learn.

(in reply to BeTheBall)
Nathan Goulette

 

Posts: 274
Joined: 1/12/2003
From: Phoenix, AZ
Status: offline

 
RE: NT authentication - 10/4/2004 19:43:35   
I know that I can use <%=request.servervariables(" LOGON_USER" )%> to get the DOMAIN\USERNAME of the person logged on. I can also get this data into a FORM FIELD without issue. However, How would I strip DOMAIN\ from the result just leaving me with the USERNAME?

Thanks.
Nate

(in reply to BeTheBall)
BeTheBall

 

Posts: 6487
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: NT authentication - 10/4/2004 19:48:02   
If you are like us, your usernames are a distinct length. Ours are 8 characters. So, I was able to simply use:

Right(Request.Servervariables("Logon_User"),8)

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to Nathan Goulette)
Nathan Goulette

 

Posts: 274
Joined: 1/12/2003
From: Phoenix, AZ
Status: offline

 
RE: NT authentication - 10/4/2004 19:54:27   
Well they are no longer than 8 characters but they are not all 8 characters. Mary Lee would only be 4 characters so unfirtunetally, I do not think that will work for this.

Any other thoughts?

(in reply to BeTheBall)
BeTheBall

 

Posts: 6487
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: NT authentication - 10/4/2004 19:58:37   
Use the Mid function. If your domain name is ABCD, then you use the following to get just the username:

<%=Mid(Request.Servervariables("Logon_User"),6)%>

The "6", tells the code to bring back all characters from the 6th position on, thus eliminating the ABCD and the "\".

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to Nathan Goulette)
Nathan Goulette

 

Posts: 274
Joined: 1/12/2003
From: Phoenix, AZ
Status: offline

 
RE: NT authentication - 10/4/2004 20:03:26   
Sweet, worked like charm!

Thanks BeTheBall!

(in reply to BeTheBall)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: NT authentication - 10/6/2004 11:04:01   
Just my $.02 - I use it dynamically like this:

<%
MyVar=request.servervariables("logon_user")
MyVar=MyVar & ""
MyPos = InstrRev(MyVar, "/", -1, 1)
UserName=Mid(MyVar,MyPos+1,Len(MyVar))
%>

That works with any domain at any length.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to Nathan Goulette)
BeTheBall

 

Posts: 6487
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: NT authentication - 10/6/2004 11:21:33   
He lives! Good to "see" you rdouglass. I will file that snippet away in my collection.

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to rdouglass)
Nathan Goulette

 

Posts: 274
Joined: 1/12/2003
From: Phoenix, AZ
Status: offline

 
RE: NT authentication - 10/6/2004 11:37:52   
Ok, I just tried this method and then in the form I put <%response.write UserName%> but it isn't showing anything.

Should I not be using the response.write to output the info?

Thanks
Nate

(in reply to BeTheBall)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: NT authentication - 10/6/2004 12:17:54   
quote:

<%
MyVar=request.servervariables("logon_user")
MyVar=MyVar & ""
MyPos = InstrRev(MyVar, "/", -1, 1)
UserName=Mid(MyVar,MyPos+1,Len(MyVar))
%>


Try DIM'ming it first:

<%
DIM UserName
MyVar=request.servervariables("logon_user")
MyVar=MyVar & ""
MyPos = InstrRev(MyVar, "/", -1, 1)
UserName=Mid(MyVar,MyPos+1,Len(MyVar))
%>

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to Nathan Goulette)
Nathan Goulette

 

Posts: 274
Joined: 1/12/2003
From: Phoenix, AZ
Status: offline

 
RE: NT authentication - 10/6/2004 12:24:47   
That didn't go either...

Any other thoughts?

(in reply to rdouglass)
Nathan Goulette

 

Posts: 274
Joined: 1/12/2003
From: Phoenix, AZ
Status: offline

 
RE: NT authentication - 10/6/2004 12:26:10   
Awe Crap.. Hang on, lemme try something. I forgot that the test web that I use, I changed the permissions to allow the anon user.

Let me test it in a web with challenge response...

(in reply to Nathan Goulette)
Nathan Goulette

 

Posts: 274
Joined: 1/12/2003
From: Phoenix, AZ
Status: offline

 
RE: NT authentication - 10/6/2004 12:36:22   
Ok, I am getting a response now but it is the username with the domain...

(in reply to Nathan Goulette)
BeTheBall

 

Posts: 6487
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: NT authentication - 10/6/2004 12:48:39   
Your slash is going the wrong way down a one-way street. Try:

MyPos = InstrRev(MyVar, "\", -1, 1)

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to Nathan Goulette)
Nathan Goulette

 

Posts: 274
Joined: 1/12/2003
From: Phoenix, AZ
Status: offline

 
RE: NT authentication - 10/6/2004 12:52:18   
Bingo!

That is better so that I can use the code and not have to worry about the length of the domain name. This works well since we have multiple domains that access the same site.

Sweet!

Thanks again guys.
Nate

(in reply to BeTheBall)
alexp

 

Posts: 3
Joined: 10/7/2004
Status: offline

 
RE: NT authentication - 10/7/2004 9:13:19   
Hi All,

Has anyone developed a web page(asp, aspx) that allows a field for
user
password
domain
once they submit these inputs, if they are successful, they go to the logged-in page.
As the viewer goes from page to page, I will want to pass their userid and that they were authenticated.
I don't need a fully written deal, I just can't seem to find the right code to get started.


Thanks in advance.

Alex

(in reply to Nathan Goulette)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: NT authentication - 10/7/2004 9:21:41   
Hi Alex and Welcome to Outfront.

I never have to code for the username/password/domain prompt if (at the server) you turn on Integrated Windows Authentication and turn *off* anonymous access to whatever directory the page is stored in. If that's setup, when you browse to a page in that directory, the server will prompt for those credentials if you're not already logged into the domain.

Then you can use the code above to do whatever you want, I tend to set a session variable and then use that on all pages I need it. For instance, the code above could be:

<%
DIM UserName
MyVar=request.servervariables("logon_user")
MyVar=MyVar & ""
MyPos = InstrRev(MyVar, "\", -1, 1)
UserName=Mid(MyVar,MyPos+1,Len(MyVar))
Session("myUserName")=UserName
%>

Then, as long as the session is valid, just use it on any asp page like this:

<%=Session("myUserName")%>

Does that help?

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to alexp)
alexp

 

Posts: 3
Joined: 10/7/2004
Status: offline

 
RE: NT authentication - 10/7/2004 9:45:53   
Hi Douglass,

Thanks for quick reply. (I like your code for stripping any domain name, I was using MID function myself, but that is not as slick as yours)

My problem is for users who are accessing web site from the Internet (everything works ok from intranet site), some user cannot type their user name-password-domain info. Also in XP, IE now displays 2 text boxes, instead of 3, so you have to use DOMAIN\USERNAME or e-mail as user name and then password.

Any way i just wanted to make it easier for users to login from outside.

Sorry for the long explanation.

Thank you,

Alex

(in reply to rdouglass)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: NT authentication - 10/7/2004 10:00:29   
If you put a default domain in the Directory Security:Edit section, the users will not have to put the domain in. Just UserName and Password will suffice (as long as they are users in the default domain of course).

You said you're not getting the dialogue box for some users? Do you have Anonymous Access turned off for that directory?

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to alexp)
alexp

 

Posts: 3
Joined: 10/7/2004
Status: offline

 
RE: NT authentication - 10/7/2004 12:33:20   
I am getting authentication box, I want to replace it with web (asp) form.

Thank you.

Alex

(in reply to rdouglass)
Page:   [1] 2   next >   >>

All Forums >> Web Development >> ASP, PHP, and Database >> NT authentication
Page: [1] 2   next >   >>
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts