Determine Domain and username used to map a network drive

WindowsAuthenticationWmicMapped Drive

Windows Problem Overview


Using Windows 7 Enterprise with SP1, but I'm hoping to get a generic answer that would apply to Windows XP/2003/2008/Vista/7.

From a command prompt, I execute a net use command to map the Z: drive to a share on another computer, but I don't use my current credentials, I specify a different domain and user to map the drive.

net use z: \rd-pc2037\C_DRIVE password /user:rd-pc2037\Administrator

The command completes successfully. Now that the drive is mapped, how can I find what Domain and Username I used to successfully map the drive? I can't seem to find what I want with the net use command.

C:\Users\rdomarat>net use
New connections will not be remembered.

Status Local Remote Network

OK Z: \rd-pc2037\C_DRIVE Microsoft Windows Network The command completed successfully.

C:\Users\rdomarat>net use Z: Local name Z: Remote name \rd-pc2037\C_DRIVE Resource type Disk Status OK

Opens 0

Connections 1

The command completed successfully.

Checking the properties of the share in Windows Explorer and looking at the security tab showed me what permissions different people would have, but I didn't see how which DOMAIN\User I had used. I searched through the registry with limited success as well.

Any thought?

Windows Solutions


Solution 1 - Windows

WMI is your friend:

> wmic netuse where LocalName="Z:" get UserName /value

UserName=rd-pc2037\Administrator

Solution 2 - Windows

None of these answers help when using alternate credentials. They only show the current, local user. That doesn't help.

To view all stored credentials, use...

rundll32.exe keymgr.dll, KRShowKeyMgr

Solution 3 - Windows

According to http://technet.microsoft.com/en-us/library/cc957215.aspx the information you want is in the registry.

I have tried the wmic-command but it showed me the locally logged in user and not the "used DOMAIN\login"


The critical info from the link above:

Registry entry HKCU\Network\{Drive letter}\UserName is a REG_SZ that specifies the username (including domain name) whose credentials were used when the network drive was mapped.

Solution 4 - Windows

Windows 11 -- some of this is useful, however Windows is still telling me that it has connected to a drive not listed in Windows Explorer, but which is not listed in computer, manage or net use or any of the options above. So Windows is storing connection information somewhere else.

There really should be a way to remove or replace persistent connections globally by username or servername.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionReg DomaratzkiView Question on Stackoverflow
Solution 1 - WindowsTerDaleView Answer on Stackoverflow
Solution 2 - WindowsJohn SuitView Answer on Stackoverflow
Solution 3 - Windowsuser3384575View Answer on Stackoverflow
Solution 4 - WindowsAli KaynView Answer on Stackoverflow