get username from visitor ?
Hello,
I'm looking for a way to get the username from the visitor from my webapplication. Any idea how to do that?
I use following code but it only works on my local developing machine:
Code:
Dim strUser As String
strUser = Request.LogonUserIdentity.Name.ToString()
Me.txtPersoon.Text = strUser.Substring(strUser.IndexOf("\") + 1)
tnx
nickname
Re: get username from visitor ?
Disable anonymous access to your virtual directory. Use windows authentication instead. You can set this in Directory security in IIS.
Re: get username from visitor ?
Quote:
Originally Posted by mendhak
Disable anonymous access to your virtual directory. Use windows authentication instead. You can set this in Directory security in IIS.
disabled anonymous access + enabled windows authentication but now the webappl. asks for user and password :-S
Re: get username from visitor ?
Yes it does. That's what you want, isn't it?
Re: get username from visitor ?
Quote:
Originally Posted by mendhak
Yes it does. That's what you want, isn't it?
No, let me explain..
I made a webapplication where the users of my network can reservate a room. And one of the fields they have to fill in is their username. Now, in my network everyone is logged in with there username, so I want to get that username and fill it in that txt automatic.
so Me.txtUsername.Text = ....???... 'filled in automaticly
Why want I to fill it in automaticly? Because else they can reservate a room on someone else his/her username..
Hope you understand now what I want.
greetz
nickname
Re: get username from visitor ?
Yes, I understood. But in order for your app to be able to access the username, you would need to use Windows authentication. The steps I've outlined above are what you need.
Re: get username from visitor ?
Quote:
Originally Posted by mendhak
Yes, I understood. But in order for your app to be able to access the username, you would need to use Windows authentication. The steps I've outlined above are what you need.
So it isn't possible without letting the visitors type their username and password? Like I said above? The problem is I would like it go automatic :blush:
greetz
nickname
Re: get username from visitor ?
You can try to create your own login mechanism, but that'd involve a start page where the users login with their credentials.
Else this is the way it goes!
Re: get username from visitor ?
I'm using Windows Authentication, and I would like to query the client's login ID for a log file. How do I grab the login? Request.LogonUserIdentity.Name.ToString does not work for me, is there something I need to include?
Re: get username from visitor ?
System.Enviorment.User......
Re: get username from visitor ?
I'm using System.Environment.UserDomainName System.Environment.UserName
DomainName returns the Server's name, and UserName returns ASPNET
Re: get username from visitor ?
Then they are not logged in as network user and you should consider just building your own user login system or using forms authin.... Mendhak has actualy used form autin so he could tell you more than I can on that front.
If they are logging in at all now you could consider putting the login data in a session var. When I build a custom login I usually make a lite weight LoginInfo class and keep it in a session var.
Example properties are User, Password, AllowedAccess and NumberOfLoginAttempts.
Re: get username from visitor ?
System.Web.HttpContext.Current.User.Identity.Name will return the visitor's login name (if Windows authentication is enabled), else the default impersonation user identity (MACHINE\ASPNET)
Re: get username from visitor ?
Just what I was looking for! Thanks!!!