Saturday, February 9, 2008

Windows Authentication

We are working on an Intranet Application which has Windows Authentication.

Following piece of code, gets you the name of the user who has logged in.

---

Imports System.Globalization


Dim GetUser As String
Dim strUID() As String
Dim User As System.Security.Principal.IPrincipal
User = System.Web.HttpContext.Current.User
GetUser = User.Identity.Name
strUID = GetUser.Split("\")
GetUser = strUID(1)

---

Once we put this code, we should get the logged in User's Name in the GetUser var.

But, we are facing some problems in a few systems where this name is getting populated incorrectly.

Instead of the Logged in user's name, we are getting the server's login name.

Googling around to solve this problem, ,no luck yet.

Once i solve this, ill put the solution here.


Happy Coding

----------------------------------------------------------------------------------------------------------------------------

0 comments: