Monday, May 10, 2021

Buggish: Unable to access MS Network Folder (IP versus HostName)

Problem (rare)

I am able to some times get to the machine's base share folders but unable to access sub-folders. I have share permissions and local machine permissions on the network machine. This seemed random because I was able to connect to other shares with IP address and hostnames. I have a different login to access the network folders than the system that I am working from.

Solution (workaround)

Be consistent with the address to the network folder. If logged in with IP address (\\10.10.10.10), continue to use IP address. If logged in with hostname (\\hostname), continue to use hostname. If you logged in with IP, then you may get access issue when using hostname. Also the same vice-versa. I was able to replicate this every time.

(Edit: 6/12/2021) Consistency is key. Using simple hostname or the fully qualified hostname (e.g. \\hostname vs \\hostname.domain.local) will also have the same issue. The trickier part to this is that net use will see these are the same and will not allow the user to provide login for both \\hostname and \\hostname.domain.local. This makes it very hard to switch. I had an post on how to remote net use but it does not work. My only solution is to reboot the system each time this needs to be corrected.

Background

We moved from one cloud platform to another. Before the group used IP addresses to connect to network folders. After the migration, we started to use hostnames. The infrastructure team also created a tunnel between the two cloud platforms. The tunnel was only accessible with IP.

When on the new system, I was still switching between IP and hostname depending on where I was copying the server address from. So I will oftentimes switch between the two depending which was readily available for me.

I do not think many people will face this problem as most people will be consistent with the address. The last oddity was that I can ping the hostname and resolves to the same IP but for some reason the destination folder does not recognize that as the same login. (I mean, I can probably guess why this is happening from the problem but not sure why it was designed this way.)


Reference

https://douglastclee.blogspot.com/2021/10/buggish-unable-to-access-ms-network.html (added 2021-10-06)

Thursday, May 6, 2021

Buggish: MS Error Copying Files to Network Share after granting permissions without reboot

I hate rebooting, so I try my best to look for solutions even if it costs me more time. In this case, I am trying to copy a file to another new network share. I get an error that I do not have permissions to do so. Then I tried to use "net use" to disconnect and reconnect with the same error.

Solution

Close all Windows Explorer windows.
  • Closing one did not resolve my issue
  • Restarting the Windows Explorer may also resolve this issue. This will likely close all Window Explorer windows anyways.
  • net use /delete does not work
    • The network share wasn't even on my net use list


Potentially Solves Another Issue

Sometimes "net use" does not allow me to add another network share with different credentials saying that it cannot manage multiple shares. I'll use "net use /delete" to remove the connection. Then when I try to add it again, it still gives me the same error. Even after I "net use" again to check, the connection is no longer there. When I try to delete it again, it says it does not exist.

I believe this may be held up by the windows explorer that I keep open.



Reference

https://stackoverflow.com/questions/24933661/multiple-connections-to-a-server-or-shared-resource-by-the-same-user-using-more

Wednesday, May 5, 2021

Info: Find my system's network folder access' user (wmic, gwmi)

 I am wrote a tool to move objects from one server to another. To do this, I use network folders. This is a web tool so I created a local user on each machine that I need access to then created a share folder giving access to my local user.

Problem

While troubleshooting on my development system, my current login user sometimes is used to access the network folder instead of the userid that I wish to use. This occurs sometimes if I use Windows Explorer to check for files before I launch my tool. If my domain account has access to the network folder, this sets my current user account to the network folder. If it does not, then none is set. This was confusing because I was able to access certain folders but not others.


My Solution

I needed a way to see what user account is used to access the network folders. The following are a couple commands that I found that were useful to me.

1. wmic netuse get remotename,username

2. gwmi -Query 'Select LocalName, RemoteName, UserName from Win32_NetworkConnection'


#2 requires powershell to execute


Additional Info

Here are a couple other commands from the page that I didn't need but may be useful to others or my future self.

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

2. gwmi -Query 'Select * from Win32_NetworkConnection' | Select-Object LocalName, RemoteName, UserName, ConnectionState | Sort-Object LocalName | ft -auto

3. rundll32.exe keymgr.dll, KRShowKeyMgr



Reference

https://stackoverflow.com/questions/9037503/determine-domain-and-username-used-to-map-a-network-drive