Results 1 to 13 of 13
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    gettting login name

    I have been trying to figure out the right magic word to find how to get the network login name on my aspx project. The Authentication mode in the web.config is set to "Windows" so I'd like to get the login name of the person going to the intranet application, so they don't have to type in name and password. I know there's a way to do this, so can anyone either a)give me the magic name of the field or b)suggest how I might capture this name? Thanks! <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
    Carpy Diem, it&#39;s .

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: gettting login name

    Does the following work?

    CreateObject("WScript.Network").UserName

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: gettting login name

    I haven't done any .Net development, so this might be too "old school" but IIS itself can determine the type of authentication used to access an ASP application. If you choose "Windows Integrated Authentication" (or whatever it is called after IIS 4.x) then IE will automatically log the user in using the credentials from their current session of Windows. This presumes the user has not disabled this feature in the applicable security zone, e.g., Intranet zone. (In Firefox, you have to add a browser preference to enable this.)

  4. #4
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: gettting login name

    Hi Peggy

    I think the thing you maybe loking for is similar to this:

    <configuration>
    <system.web>
    <authorization>
    <allow users="?"/>
    <deny users="Rudi" />
    </authorisation>
    </system.web>
    </configuration>

    If this is in your web.config it will allow access to all users except for Rudi. You will have to change the deny user to the network configuration used on your network.

    I hope that helps
    Jerry

  5. #5
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: gettting login name

    Alternatively, on thinking about it, the above just lets anybody in (apart from Rudi), If you use this:

    <configuration>
    <system.web>
    <identity
    impersonate="true"
    userName="YourDomainNameRudi"
    password="LetMeIn" />
    </system.web>
    </configuration>

    This will give access to Rudi but you must ensure that the userName and Password correspond to valid user accounts...am I on the right lines now?
    Jerry

  6. #6
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: gettting login name

    I guess I forgot to mention a few things.....

    1. I'm using VB.NET and ASPX.NET. Every example of trying to get the user's network name is unhandily written in C# and although I can read it okay, I'm also in charge of documenting the application and other people might not get the sudden shift in technologies (especially when they start with Void).

    2. I've figured out how to manipulate the web.config to block users and/or groups. However, I need this security on the forms,as well as in general.

    3. The end users want to see their name on the form they're using. So like Manager Joe wants to see a screen with all his accounts and "Manager Joe" at the top. I can get the name from the network id from a table, but darn it, I can't figure out how to get the network id.

    Does this make more sense? I do appreciate everyone's suggestions, really I do.
    Carpy Diem, it&#39;s .

  7. #7
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: gettting login name

    Hans,

    And I would put this...where? In the code behind the webform or in the html representation of the form? Sorry - I'm learning this as I go so if I sound really daft, it's not intentional.
    Carpy Diem, it&#39;s .

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: gettting login name

    You don't sound daft to me at all - I don't have the slightest idea where it should go, since I don't do web development... <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  9. #9
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: gettting login name

    Okey doke

    What you need then is the WindowsIdentity class which has the following parameters:

    AuthenticationType ie Basic or NTLM (for Windows integrated Authentication)
    IsAnonymous
    IsAuthenticated
    IsGuest
    IsSystem
    Name
    Token

    To display the user account associated with the current user you could use:

    Response.Write ( User.Identity.Name)

    This displays the full user account including the domain.

    After that I get a bit hazy but it may get you started
    Jerry

  10. #10
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: gettting login name

    ...and then using every reference at his disposal I find a link which may be useful <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15> <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    http://docs.instantasp.com/InstantForum/de...tion_roles.html
    Jerry

  11. #11
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: gettting login name

    Jerry,

    I looked at the WindowsIdentity class and it referrred to mscorlib.dll I loaded the .dll into my references but sadly, no username reference appeared under the System.Security.Principal. So I went out and spent the rent money on a huge ASP 1.1 book that, if all else fails, I can fling at my flat-screen and put it out of its misery. <img src=/S/igiveup.gif border=0 alt=igiveup width=31 height=23>

    I'll let you and everyone else know once I figure this out. It can't be nearly as difficult as it appears, right?
    Carpy Diem, it&#39;s .

  12. #12
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: gettting login name

    Okay! I got it! See, I knew I wasn't saying the magic word...here's what I did.

    1. I put <%@Import Namespace="System.Security.Principal" %> at the beginning of the html .

    2. my sql database (test mode) didn't have the correct groups set up. So fortunately, I knew how to point the groups to the database.

    3. my web.config allowed everybody (*) in the <authorization> section. By putting just my domain name and user name I was able to get "You are bleepPeggy" to display on the form. Bleep, of course, represents the name of my domain. I can easily strip off the "bleep" so I'm just left with Peggy.
    Carpy Diem, it&#39;s .

  13. #13
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: gettting login name

    <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35>

    Thanks Peggy, great you got it sorted out <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Jerry

Posting Permissions

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