Results 1 to 14 of 14

Thread: get username from visitor ?

  1. #1

    Thread Starter
    Addicted Member nickname's Avatar
    Join Date
    Sep 2004
    Location
    Europe - Belgium
    Posts
    170

    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
    Software Engineer
    DBA
    Webdesigner
    --
    to code or to be coded, that's the question

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  3. #3

    Thread Starter
    Addicted Member nickname's Avatar
    Join Date
    Sep 2004
    Location
    Europe - Belgium
    Posts
    170

    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
    Software Engineer
    DBA
    Webdesigner
    --
    to code or to be coded, that's the question

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: get username from visitor ?

    Yes it does. That's what you want, isn't it?

  5. #5

    Thread Starter
    Addicted Member nickname's Avatar
    Join Date
    Sep 2004
    Location
    Europe - Belgium
    Posts
    170

    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
    Software Engineer
    DBA
    Webdesigner
    --
    to code or to be coded, that's the question

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  7. #7

    Thread Starter
    Addicted Member nickname's Avatar
    Join Date
    Sep 2004
    Location
    Europe - Belgium
    Posts
    170

    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

    greetz

    nickname
    Software Engineer
    DBA
    Webdesigner
    --
    to code or to be coded, that's the question

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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!

  9. #9
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    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?

  10. #10
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    Re: get username from visitor ?

    System.Enviorment.User......
    Magiaus

    If I helped give me some points.

  11. #11
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: get username from visitor ?

    I'm using System.Environment.UserDomainName System.Environment.UserName
    DomainName returns the Server's name, and UserName returns ASPNET

  12. #12
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    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.
    Magiaus

    If I helped give me some points.

  13. #13
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    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)

  14. #14
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: get username from visitor ?

    Just what I was looking for! Thanks!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width