|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Act as user a different useruser A and I want to act as user B. I need to copy files out of a shared directory on a server that user B will only have access to. In the function CopyFile it appears thats everything is OK it has the User B identity object but the Server does not reconize the requerst and denies access to the file. Is there a way to get the OS to reconize the change and not just the application? Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim wp As System.Security.Principal.WindowsPrincipal Dim Domain As String = "ITFirst-HQ" Dim sPassword As String = "password" Dim sUser As String = "vsecure" Dim wi As WindowsImpersonationContext wi = NetworkSecurity.ImpersonateUser(Domain, sUser, sPassword, LogonType.LOGON32_LOGON_NETWORK, LogonProvider.LOGON32_PROVIDER_DEFAULT, True) wp = New WindowsPrincipal(NetworkSecurity.getIdentity(Domain, sUser, sPassword, LogonType.LOGON32_LOGON_NETWORK, LogonProvider.LOGON32_PROVIDER_DEFAULT, True)) AppDomain.CurrentDomain.SetThreadPrincipal(wp) AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal) Dim th As Threading.Thread = New Threading.Thread(AddressOf CopyFile) th.Start() End Sub Private Sub CopyFile() Dim th As Threading.Thread = System.Threading.Thread.CurrentThread Dim wp As WindowsPrincipal = th.CurrentPrincipal Dim id As WindowsIdentity = wp.Identity System.IO.File.Copy("\\server\SecureTest\test.pdf", "C:\test.pdf", True) End Sub Are you sure your new thread has the right impersonation token on it? In
..NET 1.1, new threads don't automatically inherit the impersonation information. You might also need to use LOGON32_LOGON_NETWORK_CLEARTEXT, but I'm not sure about that. Joe K. Show quoteHide quote "Scott" <scott.remi***@itfirst.com> wrote in message news:1112384593.539101.155450@z14g2000cwz.googlegroups.com... > How do I get a windows application to run as a different user. I am > user A and I want to act as user B. I need to copy files out of a > shared directory on a server that user B will only have access to. In > the function CopyFile it appears thats everything is OK it has the User > B identity object but the Server does not reconize the requerst and > denies access to the file. Is there a way to get the OS to reconize > the change and not just the application? > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles Button1.Click > Dim wp As System.Security.Principal.WindowsPrincipal > Dim Domain As String = "ITFirst-HQ" > Dim sPassword As String = "password" > Dim sUser As String = "vsecure" > Dim wi As WindowsImpersonationContext > wi = NetworkSecurity.ImpersonateUser(Domain, sUser, sPassword, > LogonType.LOGON32_LOGON_NETWORK, > LogonProvider.LOGON32_PROVIDER_DEFAULT, True) > wp = New WindowsPrincipal(NetworkSecurity.getIdentity(Domain, > sUser, sPassword, LogonType.LOGON32_LOGON_NETWORK, > LogonProvider.LOGON32_PROVIDER_DEFAULT, True)) > AppDomain.CurrentDomain.SetThreadPrincipal(wp) > > AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal) > Dim th As Threading.Thread = New Threading.Thread(AddressOf > CopyFile) > th.Start() > End Sub > Private Sub CopyFile() > Dim th As Threading.Thread = > System.Threading.Thread.CurrentThread > Dim wp As WindowsPrincipal = th.CurrentPrincipal > Dim id As WindowsIdentity = wp.Identity > System.IO.File.Copy("\\server\SecureTest\test.pdf", > "C:\test.pdf", True) > > End Sub >
Cannot Run Application on Windows Server 2003
Changing folder security RE: Designtime licenses, I just don't get it Custom principles and DnsPermission.Demand() User's Privileges ?cannot be instantiated under a partially trusted security policy (AllowPartiallyTrustedCallersAttri Change in ASP.Net authentication between Win2000 and Win2003 revoke Windows authentication credentials for a session Sharing Application and Session scope with ASP in IIS6 HELP Security in .Net framework |
|||||||||||||||||||||||