What happened to the GetUserName Win32 API?

I use the GetUserName Win32 API to get my computer’s username, but I found that the username is different (only in upper and lower case) when using my VPN connection at work when I was at home. I am wondering if a VPN client or other software can affect the username?

+3
source share
3 answers

The GetUserName API states:

Gets the username associated with the current thread.

Use the GetUserNameEx function to get the username in the specified format. Additional information provided by the IADsADSystemInfo interface.

So it seems that GetUserName is using IADsADSystemInfo to get the information.

If you look at the IADsADSystemInfo interface, you will see that it has a way:

get_UserName
Retrieves the active directory by the distinguished name of the current user, which is the registered user or the user personified by the calling stream.

Therefore, when you connect via VPN to the domain login, you will most likely get a different Active Directory name for the current user, and when not, you will most likely get the username that you entered (in any case, you entered in) to enter the computer using.

+2
source

This API returns the name that the user entered when logging on to the computer. Therefore, if my username is "esac", but I type "Esac", this API will return "Esac". Subsequently, if I type "ESAC", this is what it will return as well.

+2
source

Not 100% sure, but I suspect GetUserName will end the conversation with DC when you connect to your domain network, whereas it will use a local response otherwise

0
source

Source: https://habr.com/ru/post/1300197/


All Articles