Forums

ASP

This topic is locked

Retrieving Windows domain login, using if

Posted 12 Sep 2006 00:10:12
1
has voted
12 Sep 2006 00:10:12 Zack Ji posted:
Hi all:

I need to retrieve a Windows domain login name using ASP. After retrieving this name, I need to compare it to a list of acceptable names, and depending on whether the name is in the list, show or hide a particular row in a table.

I'm currently using <% Request.ServerVariables("LOGON_USER" %>, but that doesn't seem to always work. My test code is:

<p>Username: <%= Request.ServerVariables("LOGON_USER" %> </p>

And sometimes, the display just shows: "Username: "

Also, after I get the domain login, how do I show/hide the table's row?

Thanks.

Replies

Replied 28 Sep 2006 16:20:55
28 Sep 2006 16:20:55 Vince Baker replied:
To use the windows domain name you cannot have your server set to allow anonymous access. you must have it set to windows authentication.

This way the server recognises the windows user name as a variable.

Then, you can proceed to use this to filter what can and cannot be displayed.

Normally, you would create a recordset on the page that is filter by the variable to compare and see if a record is returned from your user table.

Then, using

<% if not recordsetname.eof and not recordsetname.bof then %>

display hidden stuff here

<% end if %>

will show content on the page only if the recordset was not empty (i.e. there was a username that matches that of the logged in user

Hope that explains what you need to do.

Regards

Vince Baker
<strong>DMX Zone Manager</strong>

[VBScript | ASP | HTML | CSS | SQL | Oracle | AS400 | ERP Logic | Hosting]

Reply to this topic