0

I'm searching to get back the String on the red block. The red block is the string

I already tried the following code:

Environment.UserName
My.User.Name
SystemInformation.UserName
System.Security.Principal.WindowsIdentity.GetCurrent().Name
Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
Environment.GetFolderPath(Environment.GetEnvironmentVariable("%USERNAME%"))

But this code don't work, because the computer of my company uses a domain, and the String that I need is different as the user. The user is composed only by the name, and the string is composed by the name and the first name of the employees.

Ryan M
  • 18,333
  • 31
  • 67
  • 74
ElFranchoute
  • 79
  • 2
  • 12

2 Answers2

1

I finally found what I need here

We have to import that :

“System.DirectoryServices.AccountManagement”
“System.DirectoryServices”

And write this two lines to get back the red block.

Dim currentADUser As System.DirectoryServices.AccountManagement.UserPrincipal
currentADUser = System.DirectoryServices.AccountManagement.UserPrincipal.Current
ElFranchoute
  • 79
  • 2
  • 12
0

You can try using either

HttpContext.Current.Server.MachineName

or

System.Environment.MachineName;
Nadeem_MK
  • 7,533
  • 7
  • 50
  • 61