Cmdlet Suggestion: A cmdlet to impersonate windows user

Topics: Developer Forum
Sep 20, 2006 at 12:17 AM
I would like to suggest for a cmdlet for impersonating windows user.

Suppose that if you set-location to a UNC path(e.g., cd \\Server\Share), unless you are already identified,(through CredUI), you cannot set-location into network share or other network computers.

So what I have in mind is something like(I am not sure if I have used "Impersonate" in this context correctly or not... please correct me if I am wrong),
"Impersonate-WindowsUser -ComputerName <IP or Host name> -User <user name> -Password <password>"

So after
PS> Impersonate-WindowsUser -Computer 192.168.1.1 -User:Administrator -P:password
One can set-location to "192.168.1.1" like the following
PS> cd \\192.168.1.1\SharedFolder

-- Sung Kim

Coordinator
Sep 20, 2006 at 1:47 AM
Interesting idea. I'll try to look into it. I haven't done much with impersonation of other security principals so I don't know if this is possible or not.
Sep 20, 2006 at 4:40 AM
Thank you, Keith for having an interest in the idea.
By the way, here are quick links to implementing impersonation.

Microsoft KB article
  • http://support.microsoft.com/default.aspx?scid=kb;en-us;Q306158

CodeProject.com articles written based on MS KB article above
  • http://www.codeproject.com/csharp/cpimpersonation1.asp
  • http://www.codeproject.com/csharp/zetaimpersonator.asp
Developer
Dec 20, 2006 at 2:16 PM
Impersonation is a process where a server acts on behalf of its client (using provided credentials). This is not the case, you are proposing a command which will cache your credentials using the WNetAddConnection3 function ( http://msdn2.microsoft.com/en-us/library/aa385418.aspx )
Developer
Dec 26, 2006 at 2:18 AM
This discussion has been copied to Work Item 6794. You may wish to continue further discussion there.