473,542 Members | 9,296 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Capturing Windows Login with ASP

Hi I have succesfully captured the users login detail, but I now
have a new problem I have assigned the login to a Session Variable, however
when I come to use the string stored in the variable it excludes the \ which
seperates the domain from the user name, it should be :DOMAIN\USERNAME , but
I am getting DOMAINUSERNAME which really is a pain. Anybody
know why this is happening and how I can overcome it ?

Thanks
Jul 19 '05 #1
10 2407
On Mon, 13 Sep 2004 08:17:57 +0000 (UTC), "dave"
<da**@griffineng.co.uk> wrote:
Hi I have succesfully captured the users login detail, but I now
have a new problem I have assigned the login to a Session Variable, however
when I come to use the string stored in the variable it excludes the \ which
seperates the domain from the user name, it should be :DOMAIN\USERNAME , but
I am getting DOMAINUSERNAME which really is a pain. Anybody
know why this is happening and how I can overcome it ?

Thanks


are you using vbscript or jscript?

I guess jscript. "\" is the esc chr for jscript, you might need to
replace it with 2 "\\"

hth

al.

Jul 19 '05 #2
"Harag" <ha**********************@softhome.net> wrote in message
news:4e********************************@4ax.com...
On Mon, 13 Sep 2004 08:17:57 +0000 (UTC), "dave"
<da**@griffineng.co.uk> wrote:
Hi I have succesfully captured the users login detail, but I now
have a new problem I have assigned the login to a Session Variable,
however
when I come to use the string stored in the variable it excludes the \
which
seperates the domain from the user name, it should be :DOMAIN\USERNAME ,
but
I am getting DOMAINUSERNAME which really is a pain. Anybody
know why this is happening and how I can overcome it ?

Thanks


are you using vbscript or jscript?

I guess jscript. "\" is the esc chr for jscript, you might need to
replace it with 2 "\\"

hth

al.


vbscript
Jul 19 '05 #3
"Harag" <ha**********************@softhome.net> wrote in message
news:4e********************************@4ax.com...
On Mon, 13 Sep 2004 08:17:57 +0000 (UTC), "dave"
<da**@griffineng.co.uk> wrote:
Hi I have succesfully captured the users login detail, but I now
have a new problem I have assigned the login to a Session Variable,
however
when I come to use the string stored in the variable it excludes the \
which
seperates the domain from the user name, it should be :DOMAIN\USERNAME ,
but
I am getting DOMAINUSERNAME which really is a pain. Anybody
know why this is happening and how I can overcome it ?

Thanks


are you using vbscript or jscript?

I guess jscript. "\" is the esc chr for jscript, you might need to
replace it with 2 "\\"

hth

al.


I have just realised that my problem lies elsewhere ! I am holding the user
login in a table which is passed to a new webpage via the URL and I am
reading the the variable from the query string ! This is where the character
is getting lost I believe, but I still do not know how to cure, so any more
help would be gratefully received.

Thanks

Dave
Jul 19 '05 #4
On Mon, 13 Sep 2004 09:07:07 +0000 (UTC), "dave"
<da**@griffineng.co.uk> wrote:
"Harag" <ha**********************@softhome.net> wrote in message
news:4e********************************@4ax.com.. .
On Mon, 13 Sep 2004 08:17:57 +0000 (UTC), "dave"
<da**@griffineng.co.uk> wrote:
Hi I have succesfully captured the users login detail, but I now
have a new problem I have assigned the login to a Session Variable,
however
when I come to use the string stored in the variable it excludes the \
which
seperates the domain from the user name, it should be :DOMAIN\USERNAME ,
but
I am getting DOMAINUSERNAME which really is a pain. Anybody
know why this is happening and how I can overcome it ?

Thanks


are you using vbscript or jscript?

I guess jscript. "\" is the esc chr for jscript, you might need to
replace it with 2 "\\"

hth

al.


I have just realised that my problem lies elsewhere ! I am holding the user
login in a table which is passed to a new webpage via the URL and I am
reading the the variable from the query string ! This is where the character
is getting lost I believe, but I still do not know how to cure, so any more
help would be gratefully received.

Thanks

Dave

are you encoding the querystring?

<a href="mypage.asp?sting=<%= Server.URLEncode("domain\user")
%>">click me</a>
Jul 19 '05 #5
Try this

sFullUser = trim(Request.ServerVariables ("LOGON_USER"))
sFullUser = replace(sFullUser,"/","\")
iPos = InStr(sFullUser, "\")
sDomain = Left(sFullUser, iPos - 1)
strUserName = Mid(sFullUser, iPos + 1)
make sure you have "Integrated Windows Auth" turned on your server

"dave" <da**@griffineng.co.uk> wrote in message
news:ci**********@sparta.btinternet.com...
Hi I have succesfully captured the users login detail, but I now
have a new problem I have assigned the login to a Session Variable, however when I come to use the string stored in the variable it excludes the \ which seperates the domain from the user name, it should be :DOMAIN\USERNAME , but I am getting DOMAINUSERNAME which really is a pain. Anybody
know why this is happening and how I can overcome it ?

Thanks

Jul 19 '05 #6
On Mon, 13 Sep 2004 09:07:07 +0000 (UTC), "dave"
<da**@griffineng.co.uk> wrote:
"Harag" <ha**********************@softhome.net> wrote in message
news:4e********************************@4ax.com.. .
On Mon, 13 Sep 2004 08:17:57 +0000 (UTC), "dave"
<da**@griffineng.co.uk> wrote:
Hi I have succesfully captured the users login detail, but I now
have a new problem I have assigned the login to a Session Variable,
however
when I come to use the string stored in the variable it excludes the \
which
seperates the domain from the user name, it should be :DOMAIN\USERNAME ,
but
I am getting DOMAINUSERNAME which really is a pain. Anybody
know why this is happening and how I can overcome it ?

Thanks


are you using vbscript or jscript?

I guess jscript. "\" is the esc chr for jscript, you might need to
replace it with 2 "\\"

hth

al.


I have just realised that my problem lies elsewhere ! I am holding the user
login in a table which is passed to a new webpage via the URL and I am
reading the the variable from the query string ! This is where the character
is getting lost I believe, but I still do not know how to cure, so any more
help would be gratefully received.


Either encode the query string, using HTMLEncode or URLEncode, or what
I do is split the string to domain and user and store them separately.

Jeff
Jul 19 '05 #7
"Jeff Cochran" <je*********@zina.com> wrote in message
news:41*****************@msnews.microsoft.com...
On Mon, 13 Sep 2004 09:07:07 +0000 (UTC), "dave"
<da**@griffineng.co.uk> wrote:
"Harag" <ha**********************@softhome.net> wrote in message
news:4e********************************@4ax.com. ..
On Mon, 13 Sep 2004 08:17:57 +0000 (UTC), "dave"
<da**@griffineng.co.uk> wrote:

Hi I have succesfully captured the users login detail, but I now
have a new problem I have assigned the login to a Session Variable,
however
when I come to use the string stored in the variable it excludes the \
which
seperates the domain from the user name, it should be :DOMAIN\USERNAME ,
but
I am getting DOMAINUSERNAME which really is a pain. Anybody
know why this is happening and how I can overcome it ?

Thanks
are you using vbscript or jscript?

I guess jscript. "\" is the esc chr for jscript, you might need to
replace it with 2 "\\"

hth

al.


I have just realised that my problem lies elsewhere ! I am holding the
user
login in a table which is passed to a new webpage via the URL and I am
reading the the variable from the query string ! This is where the
character
is getting lost I believe, but I still do not know how to cure, so any
more
help would be gratefully received.


Either encode the query string, using HTMLEncode or URLEncode, or what
I do is split the string to domain and user and store them separately.

Jeff


Excuse my ignorance, but how do I split the string ? as I feel this would be
the best way forward.

Dave
Jul 19 '05 #8
On Mon, 13 Sep 2004 16:05:32 +0000 (UTC), "dave"
<da**@griffineng.co.uk> wrote:

[snipped a load of lines]
Jeff
Excuse my ignorance, but how do I split the string ? as I feel this would be
the best way forward.

Dave


Extracted from the MS scripting documents v5.6

HTH
Al.

----------------------------------------------------------
Returns a zero-based, one-dimensional array containing a specified
number of substrings.

Split(expression[, delimiter[, count[, compare]]])
Arguments
expression
Required. String expression containing substrings and delimiters. If
expression is a zero-length string, Split returns an empty array, that
is, an array with no elements and no data.
delimiter
Optional. String character used to identify substring limits. If
omitted, the space character (" ") is assumed to be the delimiter. If
delimiter is a zero-length string, a single-element array containing
the entire expression string is returned.
count
Optional. Number of substrings to be returned; -1 indicates that all
substrings are returned.
compare
Optional. Numeric value indicating the kind of comparison to use when
evaluating substrings. See Settings section for values.
Settings
The compare argument can have the following values:

Constant Value Description
vbBinaryCompare 0 Perform a binary comparison.
vbTextCompare 1 Perform a textual comparison.

Remarks
The following example uses the Split function to return an array from
a string. The function performs a textual comparison of the delimiter,
and returns all of the substrings.

Dim MyString, MyArray, Msg
MyString = "VBScriptXisXfun!"
MyArray = Split(MyString, "x", -1, 1)
' MyArray(0) contains "VBScript".
' MyArray(1) contains "is".
' MyArray(2) contains "fun!".
Msg = MyArray(0) & " " & MyArray(1)
Msg = Msg & " " & MyArray(2)
MsgBox Msg


Jul 19 '05 #9
Thanks guys, has sorted out my problems. Cant thank you all enough !

Dave
"JP SIngh" <no**@none.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Try this

sFullUser = trim(Request.ServerVariables ("LOGON_USER"))
sFullUser = replace(sFullUser,"/","\")
iPos = InStr(sFullUser, "\")
sDomain = Left(sFullUser, iPos - 1)
strUserName = Mid(sFullUser, iPos + 1)
make sure you have "Integrated Windows Auth" turned on your server

"dave" <da**@griffineng.co.uk> wrote in message
news:ci**********@sparta.btinternet.com...
Hi I have succesfully captured the users login detail, but I now
have a new problem I have assigned the login to a Session Variable,

however
when I come to use the string stored in the variable it excludes the \

which
seperates the domain from the user name, it should be :DOMAIN\USERNAME ,

but
I am getting DOMAINUSERNAME which really is a pain. Anybody
know why this is happening and how I can overcome it ?

Thanks


Jul 19 '05 #10
>> Either encode the query string, using HTMLEncode or URLEncode, or what
I do is split the string to domain and user and store them separately.
Excuse my ignorance, but how do I split the string ? as I feel this would be
the best way forward.


I use:

strLogonUser = Request.ServerVariables("LOGON_USER")
tmpUserID = Split(strLogonUser,"\")
strUserDomain = tmpUserID(0)
strUserName = tmpUserID(1)

Now you can use UserName, UserDomain or LogonUser, whichever is
appropriate for your needs.

Jeff
Jul 19 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1541
by: talk_positive | last post by:
Hi... I have made a asp page that accepts some data from user and stores it in MS Access database. Now...I want to identify the user who filled the form and store this information in database. About the enviornment....the server has Windows 2000 server installed. Clients have Windows XP. Server also has Exchange 2003 installed and every...
3
1939
by: Alex Marsh | last post by:
I want to record the user who created a record (and the user who last changed the record), either initials or a short name How can I capture a user-id? Can it be done from the user info in the Windows Registry, or would it involve setting up Security and getting users to log on to Access? Any suggestions appreciated
1
1292
by: Brad | last post by:
Hello all. I'm trying to convert an application with a SQL Server 2000 back end and an Access front-end. The back end is fine. I'm just trying to give it a web front-end using ASP.NET. The problem is that since Access runs on the client machine, it gathers NT authentication information at the client and uses that to access the database. ...
14
2517
by: Brent Burkart | last post by:
I am trying to capture the Windows Authenticated username, but I want to be able to capture the login name that exists in IIS, not Windows. In order to enter my company's intranet through the internet, they have to login. I want to be able to capture that login versus their Windows login because I need to know who they are from any computer...
4
1726
by: Paul Ponzelli | last post by:
I'm using the VB.NET language in ASP.NET, with Windows XP on the desktops and Windows 2003 on the network servers. When users log on, they have to enter a user name and password in the netowrk operating system. Is there a function or other means I can use to capture the Windows 2003 login user name for use in my code? Thanks in advance, ...
6
1360
by: =?Utf-8?B?Q2h1Y2sgUA==?= | last post by:
I have a Role Provider with a subdirectory protected via the web.config. Forms authentication is used. If a person who is not in the role tries to access a page in the directory, the browser is redirected to the forms authentication logon page. Is there a way to prevent this behavior? I would prefer to just show the user an access denied...
1
1712
by: Brave | last post by:
I create email forms in ASP for my company, and have a question about capturing the users login information to keep them from having to enter their name on every form. I am hoping to pre-populate the login information into a form field. Can someone give me a general idea of how this can be done, and what I make need to be aware of. I also...
2
7681
pod
by: pod | last post by:
Hello I need to capture the Windows Network Username from an intranet web site. The site is an ASP - VBScript based web site that sits on a server which is on the same network as the users In my default website Authentication Methods, I have unchecked "Anonymous access" and have only "Integrated Windows authentication" checked My...
0
7384
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7322
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7567
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7316
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5862
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4878
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1790
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.