impersonation

Impersonation on remote service says Login failed for user 'NT Authority\Anonymous Logon'

送分小仙女□ 提交于 2019-12-10 15:08:42
问题 I have a service that I want to when accessing databases I want to access databases to use the calling identities credentials. Before I access a particular database I do an impersonation by var winId = HttpContext.Current.User.Identity as WindowsIdentity; var ctx = winId.Impersonate(); //Access Database ctx.Undo(); This scenario works fine when the service runs locally on my PC. However when deployed on another remote PC I get the error: Login failed for user 'NT Authority\Anonymous Logon" as

Impersonation: ASP.Net MVC Controller Action vs. Web Forms

霸气de小男生 提交于 2019-12-10 14:34:44
问题 Is there a difference with impersonation between an ASP.Net MVC controller actions vs. an ASP.Net Web Form? Using the exact same code within the same web project, I am able to successfully impersonate the Windows user when connecting to SQL Server from a Web Form but not from the Controller Action. Here is the code sample I am testing from each: string sqlQuery = @"SELECT Top 10 FullName FROM Customer"; // Connect to the database server. You must use Windows Authentication; SqlConnection

How to impersonate another user?

蓝咒 提交于 2019-12-10 14:18:59
问题 I'm working on an ASP.net app and i'm trying to impersonate a user I'm creating a windowsIdentity with a token WindowsIdentity winId = new WindowsIdenty( token ); this token was got by calling the un managed code [DllImport("advapi32.dll")] public static extern int LogonUserA(String lpszUserName, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken); is there any other way to get a token without using this advapi32.dll unmanaged code? tks 回答1:

Windows Impersonation and duplicating tokens

孤者浪人 提交于 2019-12-10 13:54:40
问题 I have an asp.net project where the request will delegate work to the background (via quartz.net). The web application is using windows authentication and impersonation. I would also like to impersonate the current user on the background thread as well. I have read how to impersonate a user with a supplied domain name, username and password and calling out the kernel. That method works. IntPtr token; var successfullLogon = LogonUser(userName, password, domain, logonType, logonProvider, out

Impersonating ASP.NET claims identity to windows identity

ぃ、小莉子 提交于 2019-12-10 13:46:53
问题 I have an ASP.NET application which uses claims bases authentication against ADFS. I also map it to a WindowsClaimsIdentity by using the Claims to Windows Identity Service. That works fine. But now I need to impersonate the current request/thread so I can access a service which is not claims aware. How should I do that? Should I acquired a WindowsImpersonationContext in the Application_PostAuthenticate event and save that in the HttpContext.Items and then in the Application_EndRequest call

Trouble setting ownership when impersonating

☆樱花仙子☆ 提交于 2019-12-10 12:27:32
问题 Here is my code: logonSuccess = LogonUserW(userPartW, domainPartW, pwdW, LOGON32_LOGON_BATCH, LOGON32_PROVIDER_DEFAULT, &token); Int result1 = SetNamedSecurityInfo("C:\\file.crt", SE_FILE_OBJECT, OWNER_SECURITY_INFORMATION, yveri, NULL, NULL, NULL); fprintf(stderr, "result -> %d.\n", result1); //which gives me 0 if (ImpersonateLoggedOnUser(token) == FALSE) { printf("Imperesonating failed.\n"); return -1; } Int result2 = SetNamedSecurityInfo("C:\\Users\\nx\\.nx\\config\\authorized.crt", SE

How do you do Impersonation in UWP?

三世轮回 提交于 2019-12-10 11:13:11
问题 I am working on UWP application. A scenario came where i want to change the current context user(current login user).For that i am trying to implement Impersonation in UWP. In general windows or web application I am able to change the current context user by using sample code available on following link: http://www.codeproject.com/Articles/10090/A-small-C-Class-for-impersonating-a-User But i am unable to implement this in UWP. I want to implement impersonation in UWP. 回答1: Impersonation is

'Item Does Not Exist' error reading SharePoint 2010 List

ぃ、小莉子 提交于 2019-12-10 10:24:59
问题 I have a list in SharePoint 2010. If I add items to the list programmatically (via a custom webpart), I can later read those items and show them in other web parts. However, if I attempt to read a list item added through the web interface, I get the following error in my webpart: Item does not exist. The page you selected contains an item that does not exist. It may have been deleted by another user.0x81020016 The weird part is, in the debugger, I see that the list item is properly read. I'm

asp.net WindowsImpersonationContext function

纵饮孤独 提交于 2019-12-10 10:22:01
问题 Can anyone please explain the function of the lines below: WindowsIdentity wId = (WindowsIdentity)HttpContext.Current.User.Identity; WindowsImpersonationContext wIdCon = wId.Impersonate(); That is used on a POST method with IIS basic authentication and works fine. If however the IIS authentication is set to windows the above no longer works. There is simply way too much code to dump for an example. 回答1: The call to Impersonate() makes IIS pretend to be the requesting user from that point on.

Getting the default credentials?

爷,独闯天下 提交于 2019-12-10 09:33:09
问题 I have page A.aspx in my domain this page (in its c# codes) makes a request to another page.( B.aspx ). - which is in my domain also the whole site is in windows authentication HttpWebRequest loHttp = (HttpWebRequest)WebRequest.Create("http://mydom.com/b.aspx"); loHttp.UseDefaultCredentials = true; loHttp.Timeout = 100000; HttpWebResponse loWebResponse = (HttpWebResponse)loHttp.GetResponse(); Encoding enc = Encoding.GetEncoding("UTF-8"); // Windows default Code Page StreamReader