impersonation

'Item Does Not Exist' error reading SharePoint 2010 List

一笑奈何 提交于 2019-12-06 03:37:57
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 pulling what's left of my hair out over this one. Any ideas? Here's the answer for anyone who cares: I

Impersonation in ASP.NET MVC

孤者浪人 提交于 2019-12-06 02:05:36
问题 I have an Action that needs to read a file from a secure location, so I have to use impersonation to read the file. This code WORKS: [AcceptVerbs(HttpVerbs.Get)] public ActionResult DirectDownload(Guid id) { if (Impersonator.ImpersonateValidUser()) { try { var path = "path to file"; if (!System.IO.File.Exists(path)) { return View("filenotfound"); } var bytes = System.IO.File.ReadAllBytes(path); return File(bytes, "application/octet-stream", "FileName"); } catch (Exception e) { Log.Exception(e

SQL Server Execute Impersonation

你离开我真会死。 提交于 2019-12-05 23:43:49
问题 What is the diffrence between... execute as user = 'testuser' AND execute as login = 'testuser' I am executing a cross database procedure under these logins and it works with the exececute as login but not the execute as user. It is saying the server principal "testuser" is nt able to access the database "xxx" under the securty context. When i SELECT SYSTEM_USER after both commands I see that it is set to 'testuser' 回答1: execute as login provides impersonation to the entire server, since

C# Directory.exist always return false on the local network

久未见 提交于 2019-12-05 20:34:59
I'm trying to check wether a directory exist on not or a local network. After some research on stackoverflow and MSDN, I develop my code by using impersonate method. The problem is it's not working very well, The Directory.exists() method always return False Here you have my code (it's nearly the same as the one from MSDN ): public sealed class SafeTokenHandle : SafeHandleZeroOrMinusOneIsInvalid { private SafeTokenHandle() : base(true) { } [DllImport("kernel32.dll")] [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] [SuppressUnmanagedCodeSecurity] [return: MarshalAs

Multilevel usage of thread impersonation

随声附和 提交于 2019-12-05 18:34:55
I'm having some issues with some long-ago written classes that do thread-level impersonation and process spawning. The problem seems to be that my usage of these utility classes is above and beyond what anyone else has tried to do with them. The first does thread-level impersonation by using OpenThreadToken and DuplicateToken along with ImpersonateLoggedOnUser. The second attempts to create a process using CreateProcessAsUser with a token obtained with OpenThreadToken / DuplicateToken. The issue I'm running into is that I have: Thread 1 running in IIS with the correct user Thread 2 that is

Getting the default credentials?

左心房为你撑大大i 提交于 2019-12-05 17:55:18
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 loResponseStream = new StreamReader(loWebResponse.GetResponseStream(), enc); string lcHtml = loResponseStream

how to use hashed password in impersonate of ASP.NET

╄→尐↘猪︶ㄣ 提交于 2019-12-05 17:30:54
I have an ASP.NET application that requires impersonation as an administrator user. In web.config: <identity impersonate="true" userName="administrator" password="password"/> The customer complained about saving the password in clear text format. Is there a way to save the password here as hashed? aspnet_regiis with the appropriate switch should do the trick, see this article. 来源: https://stackoverflow.com/questions/2912903/how-to-use-hashed-password-in-impersonate-of-asp-net

Impersonation and delegation (with SQL Server) in ASP.NET

南笙酒味 提交于 2019-12-05 16:51:45
I've written a simple ASP.NET application that works as a frontend for a simple MSSQL database. The application is accessible over the Internet. There are two physical servers involved: a WS2008R2 Active Directory domain controller which is also running MSQL Server 2008 R2, and another server, the webserver (WS2008R2/IIS7.5) where my application resides. The Application Pool for my application "FooPool" has its own AD User identity it runs under "FooUser". FooUser does not have any permission to access the SQL Server database, instead only my own personal user account "MyUser" has that

WCF Parallel Impersonation

半城伤御伤魂 提交于 2019-12-05 16:04:28
I have a WCF service with "ImpersonationOption.Required". The impersonation does not seem to flow through when using parallelism. For example: Parallel.ForEach(items => results.Add(SystemUtil.WindowsUser.Name) Will return a number with the impersonated user, and a number with the app pool user. Can impersonation be made to work with parallelism? Best, Marc Update: This is actual code on the IIS Service side. [OperationBehavior(Impersonation = ImpersonationOption.Required)] public string[] WhoAmI(int numOfTests) { var tests = new List<int>(); for (var i = 0; i < numOfTests; i++) tests.Add(i);

Copying a file to a network share which I don't have access to

旧巷老猫 提交于 2019-12-05 13:35:40
This is an extension of this question I am trying to copy a file from my local user's temp folder to a remote file share. I do not have access to the remote file share, so I have to impersonate a user who does. Now, I can successfully read a file from the remote server and copy it locally, however I cannot write a local file to the share, since it gives me the error: Access denied for the LOCAL file (as I am now impersonating another user). If you need some code I can post it. Managed to find the answer, I simply had to create a FileStream to the local file BEFORE impersonating the remote user