• gettting login name

    Author
    Topic
    #433793

    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! thankyou

    Viewing 5 reply threads
    Author
    Replies
    • #1021223

      Does the following work?

      CreateObject(“WScript.Network”).UserName

      • #1021310

        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.

        • #1021311

          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… grin

        • #1021312

          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

          • #1021756

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

            I’ll let you and everyone else know once I figure this out. It can’t be nearly as difficult as it appears, right?

        • #1021314

          …and then using every reference at his disposal I find a link which may be useful shrug grin

          http://docs.instantasp.com/InstantForum/de…tion_roles.html%5B/url%5D

    • #1021275

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

    • #1021307

      Hi Peggy

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

      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

    • #1021308

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

      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?

    • #1021309

      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.

    • #1021872

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

      1. I put 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 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.

    Viewing 5 reply threads
    Reply To: gettting login name

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: