papa_k Posted November 29, 2006 Posted November 29, 2006 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 Quote without time nothing ever ends
Administrators PlausiblyDamp Posted November 29, 2006 Administrators Posted November 29, 2006 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
papa_k Posted November 30, 2006 Author Posted November 30, 2006 (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 November 30, 2006 by papa_k Quote without time nothing ever ends
MrPaul Posted November 30, 2006 Posted November 30, 2006 Using Windows authentication You do not specify whether you understood everything PlausiblyDamp mentioned. 1. Configure IIS to allow Windows authentication Open IIS Right click the website in the treeview on the left and select Properties Go to the Directory Security tab In the Authentication and access control section click Edit Ensure Enable anonymous access is unchecked Ensure Integrated Windows authentication is checked Click OK 2. Configure your ASP.Net application to use Windows authentication Open web.config Find the authentication element within system.web. If it does not exist, add it Ensure it looks like this: <authentication mode="Windows" /> 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: Quote Never trouble another for what you can do for yourself.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.