windows-identity

Impersonation Middleware in an Asp.Net Core Intranet app for Windows-Identity

故事扮演 提交于 2021-01-29 08:08:47
问题 Before I explain my problem, here's our scenario: Scenario We write software only for our intranet Windows users (currently managed by local Active Directory but in future it is possible we migrate to Azure-AD). Up to yet there is an old monolithic Winforms app which communicates directly with the database using datasets. All requests to the database happens with WindowsIdentity (end-user context), so the database knows the end user. For future development we want to use a Web API for

What is the difference between Owner and User (WindowsIdentity)?

大城市里の小女人 提交于 2021-01-28 21:56:38
问题 When getting the username and/or SID of the current user, what is the preferred method? Is it using: WindowsIdentity.GetCurrent().Owner Or: WindowsIdentity.GetCurrent().User What is the difference between the two? This would be a great question for SuperUser.com, but alas, it's not live yet. Thanks! 回答1: What you usually want is the User. Every security object in windows has permissions and owner. The user is also a security object so it has permissions and owner. The ownership means that the

What is the difference between Owner and User (WindowsIdentity)?

余生颓废 提交于 2021-01-28 21:40:56
问题 When getting the username and/or SID of the current user, what is the preferred method? Is it using: WindowsIdentity.GetCurrent().Owner Or: WindowsIdentity.GetCurrent().User What is the difference between the two? This would be a great question for SuperUser.com, but alas, it's not live yet. Thanks! 回答1: What you usually want is the User. Every security object in windows has permissions and owner. The user is also a security object so it has permissions and owner. The ownership means that the

How do I set up .NET WindowsAuthentication - the name always shows up as “IIS APPPOOL\Classic .NET AppPool” when I want it to use the actual user

烈酒焚心 提交于 2020-03-13 13:12:45
问题 I'm using the following code to authenticate via Kerberos. IntPtr logonToken = WindowsIdentity.GetCurrent().Token; string authenticationType = "WindowsAuthentication"; WindowsIdentity windowsIdentity = new WindowsIdentity(logonToken, authenticationType); //windowsIdentity.Name == equals "IIS APPPOOL\Classic .NET AppPool" when I want it to be the user This only happens when I try and run my .NET application the Web Server. If I run the code locally on my machine for debugging, it shows my

How to store WindowsIdentity for use at a later, indeterminate time

北城余情 提交于 2020-01-05 02:36:17
问题 I've a WCF service that queues and executes commands on behalf of the user at a later, indeterminate time. I was hoping to store the WindowsIdentity as a byte array and stuff it into a database, and then later deserialize and use that object. Some of the time, the service performs as expected: it correctly serializes, stores, deserializes, and executes the command as the user. Other times, I get an error "Exception has been thrown by the target of an invocation" when deserializing the

can WindowsIdentity.GetCurrent() return null?

孤街浪徒 提交于 2020-01-02 00:56:06
问题 ReSharper warns me about a possible NullReferenceException in WindowsIdentity windowsIdentity = new WindowsIdentity(WindowsIdentity.GetCurrent().Token); I looked in MSDN doc but didn't see any mention of this. Also, it doesn't make sense since if you run an executable, you have to be logged on. Is this just a ReSharper search pattern? 回答1: Using ILSpy, you can look at a de-compiled version of GetCurrent and GetCurrentInternal , which GetCurrent calls. The result is: GetCurrent: public static

WindowsIdentity.Impersonate in ASP.NET randomly “Invalid token for impersonation - it cannot be duplicated”

女生的网名这么多〃 提交于 2020-01-01 09:24:01
问题 I have an ASP.NET app that requires users to sign in with their domain accounts using Basic Authentication. The user can make a selection, then press a button. At some point after pressing the button is this code: WindowsIdentity.Impersonate(userIdentity.Token) . userIdentity is of type WindowsIdentity , and it was previously set to (WindowsIdentity)User.Identity . userIdentity is stored as a session variable, and I think that's because, after the button is pressed, the page containing this

WindowsIdentity.Impersonate in ASP.NET randomly “Invalid token for impersonation - it cannot be duplicated”

瘦欲@ 提交于 2020-01-01 09:22:08
问题 I have an ASP.NET app that requires users to sign in with their domain accounts using Basic Authentication. The user can make a selection, then press a button. At some point after pressing the button is this code: WindowsIdentity.Impersonate(userIdentity.Token) . userIdentity is of type WindowsIdentity , and it was previously set to (WindowsIdentity)User.Identity . userIdentity is stored as a session variable, and I think that's because, after the button is pressed, the page containing this

HTTPContext.Current.User.Identity.Name not working inside a control?

て烟熏妆下的殇ゞ 提交于 2019-12-25 17:01:25
问题 I have a label and I want to set text of this label to HTTPContext.Current.User.Identity.Name So I wrote Text = '<%=HTTPContext.Current.User.Identity.Name %>' but it doesn't work, however when I wrote this outside of the lable for example: <h2> <%=HTTPContext.Current.User.Identity.Name %> </h2> it works. 回答1: <asp:Label ID="lbUserName" runat="server" Text='<%# HttpContext.Current.User.Identity.Name %>' /> in Page_Load if (!Page.IsPostBack ) { lbUserName.DataBind(); } 回答2: use label like this

Impersonation throws FileNotFoundException with WindowsIdentity in Powershell

时光毁灭记忆、已成空白 提交于 2019-12-23 09:33:22
问题 I am encountering a somewhat weird error with performing impersonation in PowerShell and C#. Executing the folowing code does not show any errors. PSObject result = null; using (PowerShell powershell = PowerShell.Create()) { RunspaceConfiguration config = RunspaceConfiguration.Create(); powershell.Runspace = RunspaceFactory.CreateRunspace(config); powershell.Runspace.Open(); powershell.AddScript(String.Format(CmdletMap[PSVocab.OsBootTime], this.ComputerName)); result = powershell.Invoke()