Hello,
How to display domain user full name using ASP.Net v2.0
In ASP I used to write the following simple code:
==============
sFullUser = Request.ServerVariables ("LOGON_USER")
iPos = InStr(sFullUser, "\")
sDomain = Left(sFullUser, iPos - 1)
sUser = Mid(sFullUser, iPos + 1)
Set usr = GetObject("WinNT://" & sDomain & "/" & sUser)
ShowFullName = usr.FullName
==============

Show domain user full name
Roman T
You could also use
Response.Write("Name="& System.Security.Principal.WindowsIdentity.GetCurrent().Name);
-Shawn
regina
I managed to solve my problem and thought about posting it here.
It may help someone.
=======================
Dim LogonUser As String = Request.ServerVariables("LOGON_USER")
Dim Pos As Integer = InStr(LogonUser, "\")
Dim Domain As String = Left(LogonUser, Pos - 1)
Dim User As String = Mid(LogonUser, Pos + 1)
Dim DirectoryEntryPath As String = ("WinNT://" & Domain & "/" & User)
Dim objUser As New DirectoryEntry(DirectoryEntryPath)
Response.Write("<br>Name=" & objUser.Properties("Name").Value.ToString)
Response.Write("<br>FullName=" & objUser.Properties("FullName").Value.ToString)
Response.Write("<br>Description=" & objUser.Properties("Description").Value.ToString)
Response.Write("<br>PrimaryGroupID=" & objUser.Properties("PrimaryGroupID").Value.ToString)
=======================and in the top of the page we have to include the following:
<%@ Assembly name="System.DirectoryServices, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"%>
<%@ Import Namespace="System.DirectoryServices" %>
You may also use it to retrieve the following properties:
UserFlags, MaxStorage, PasswordAge, PasswordExpired, LoginHours, BadPasswordAttempts, LastLogin, HomeDirectory, LoginScript, Profile, HomeDirDrive, Parameters, PrimaryGroupID, MinPasswordLength, MaxPasswordAge, MinPasswordAge, PasswordHistoryLength, AutoUnlockInterval, LockoutObservationInterval, MaxBadPasswordsAllowed, RasPermissions, objectSid