Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think you're on the right way, the problem with "Access denied" is due to ASP.NET process running with ASPNET user which has limited rights and that's what you're getting an error. What you could do is to set up imersnation for your web application. You can it either by changing web.config or in code. More about impersonation you can read <a href="http://support.microsoft.com/kb/306158" rel="nofollow noreferrer">here</a></p> <p>web.comfig is realtively easy, you need to add a following line into the system.web section of your web.config</p> <pre><code>&lt;identity impersonate="true" userName="domain\user" password="password" /&gt; </code></pre> <p>user need to have admin rights on the server</p> <p>if you would like to perform the impersonation in code below is an example of how you could do this:</p> <pre><code>... WindowsImpersonationContext context = ImpersonateUser("domain", "user", "password"); // kill your process context.Undo(); ... [DllImport("advapi32.dll")] private static extern bool LogonUser( String lpszUsername, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken); [DllImport("advapi32.dll")] private static extern bool DuplicateToken( IntPtr ExistingTokenHandle, int ImpersonationLevel, ref IntPtr DuplicateTokenHandle); [DllImport("kernel32.dll")] private static extern bool CloseHandle(IntPtr hObject); private enum SecurityImpersonationLevel { SecurityAnonymous, SecurityIdentification, SecurityImpersonation, SecurityDelegation } private enum LogonTypes { LOGON32_PROVIDER_DEFAULT=0, LOGON32_LOGON_INTERACTIVE=2, LOGON32_LOGON_NETWORK=3, LOGON32_LOGON_BATCH=4, LOGON32_LOGON_SERVICE=5, LOGON32_LOGON_UNLOCK=7, LOGON32_LOGON_NETWORK_CLEARTEXT=8, LOGON32_LOGON_NEW_CREDENTIALS=9 } public static WindowsImpersonationContext ImpersonateUser(string domain, string username, string password) { WindowsImpersonationContext result = null; IntPtr existingTokenHandle = IntPtr.Zero; IntPtr duplicateTokenHandle = IntPtr.Zero; try { if (LogonUser(username, domain, password, (int)LogonTypes.LOGON32_LOGON_NETWORK_CLEARTEXT, (int)LogonTypes.LOGON32_PROVIDER_DEFAULT, ref existingTokenHandle)) { if (DuplicateToken(existingTokenHandle, (int)SecurityImpersonationLevel.SecurityImpersonation, ref duplicateTokenHandle)) { WindowsIdentity newId = new WindowsIdentity(duplicateTokenHandle); result = newId.Impersonate(); } } } finally { if (existingTokenHandle != IntPtr.Zero) CloseHandle(existingTokenHandle); if (duplicateTokenHandle != IntPtr.Zero) CloseHandle(duplicateTokenHandle); } return result; } </code></pre> <p>hope this helps, regards</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload