Nt Id

papa_k

Well-known member
Joined
Jun 12, 2003
Messages
77
Location
UK
I havent been here for a while, but i am now stuck again. I want to get the users NT ID from their machine when they enter my asp.net VB (VWD) website.

How do i do this using VWD? I need to validate just the user id (no passwords or the like) against a SQL database.

Papa
 
Code:
User.Identity.Name
should return the login name of the current user. This assumes however that IIS is configured to allow Windows Authentication and the ASP.Net app is also set for Windows Authentication - also if you allow anonymous access to your pages the browser will not be required to authenticate and you will have no useful information.
 
This seemed to work!


:o)


Code:
Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim chrName

        chrName = User.Identity.Name

        lblUser.Text = chrName


    End Sub
End Class
 
Last edited by a moderator:
Using Windows authentication

You do not specify whether you understood everything PlausiblyDamp mentioned.

1. Configure IIS to allow Windows authentication
  1. Open IIS
  2. Right click the website in the treeview on the left and select Properties
  3. Go to the Directory Security tab
  4. In the Authentication and access control section click Edit
  5. Ensure Enable anonymous access is unchecked
  6. Ensure Integrated Windows authentication is checked
  7. Click OK

2. Configure your ASP.Net application to use Windows authentication
  1. Open web.config
  2. Find the authentication element within system.web. If it does not exist, add it
  3. Ensure it looks like this:
    Code:
    <authentication mode="Windows" />
  4. Save web.config

3. Use User.Identity.Name in code

Code:
Partial Class _Default
    Inherits System.Web.UI.Page

    Dim userName As String

    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
        MyBase.OnLoad(e)

        Get userName
        userName = User.Identity.Name

        Do something with userName here
    End Sub
End Class

Good luck :cool:
 
Back
Top