Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I haven't 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

without time nothing ever ends
  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted (edited)

This seemed to work!

 

 

:o)

 

 


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

Edited by papa_k
without time nothing ever ends
Posted

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:
    <authentication mode="Windows" />


  4. Save web.config

 

3. Use User.Identity.Name in 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:

Never trouble another for what you can do for yourself.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...