Questions tagged [windows-identity]

Use this tag to better reference questions about WindowsIdentity allowing to encapsulate information about Windows accounts.

The WindowsIdentity object encapsulates information about Windows accounts. You use the WindowsIdentity object if you want to make authorization decisions based on a user's Windows account information.

For example, using WindowsIdentity and WindowsPrincipal objects, you can write an application that requires all users to be currently validated by a Windows NT or Windows 2000 domain. You can also allow certain domain accounts to access your application while denying access to others.

To find more information :

204 questions
7
votes
1 answer

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

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:…
Aren Cambre
  • 6,540
  • 9
  • 30
  • 36
7
votes
2 answers

IsInRole Getting New Security Token

I'm using WindowsPrincipal's IsInRole method to check group memberships in WPF and Winforms apps. I'm generating an identity token which can be for any AD user (not necessarily the user who's actually logged into the computer--depending on what I'm…
Jeff
  • 8,020
  • 34
  • 99
  • 157
7
votes
2 answers

Message: ID4243: Could not create a SecurityToken. A token was not found in the token cache and no cookie was found in the context

We're getting the exact same error as in this thread ... in our production environment. [WIF Security Token Caching Does anybody have a fix to this error ? Message: ID4243: Could not create a SecurityToken. A token was not found in the token cache…
Lord02
  • 121
  • 1
  • 8
6
votes
1 answer

Impersonation throws FileNotFoundException with WindowsIdentity in Powershell

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()) { …
Jae
  • 105
  • 5
6
votes
1 answer

How to copy file from UNC-share to local system?

I'm stuck with this question. I have UNC share, I know account details, which has fullaccess, but it doesn't have access to my local system. I can get access to remote UNC with : var token = default(IntPtr); var context =…
Degot
  • 139
  • 4
  • 8
6
votes
1 answer

How to copy file from a specific folder to a shared folder in C#?

I am trying to copy existing file from a specific folder to a shared folder. So this is the code: if (!System.IO.File.Exists(fullPath)) { using (WindowsIdentity.GetCurrent().Impersonate()) { …
Whirlwind
  • 14,286
  • 11
  • 68
  • 157
6
votes
6 answers

Registry ReadString method is not working in Windows 7 in Delphi 7

The following code sample used to return me windows id before, but now it doesn't work, and returns empty string, dunno why. function GetWindowsID: string; var Registry: TRegistry; str:string; begin Registry :=…
Tofig Hasanov
  • 3,303
  • 10
  • 51
  • 81
6
votes
1 answer

Why do Thread.CurrentPrincipal.Identity and WindowsIdentity.GetCurrent() differ when impersonation is turned on?

I enabled impersonation and Windows authentication. But Thread.CurrentPrincipal.Identity.Name returns the name of authenticated user and…
5
votes
2 answers

How do I handle the event SessionSecurityTokenReceived in Global.asax?

I'm trying to set up sliding sessions in WIF and need to handle SessionSecurityTokenReceived. I'm sure I'm doing something dumb here... but VS2010 keeps on telling me that There is no applicable variable or member in the spot illustrated below. Can…
makerofthings7
  • 60,103
  • 53
  • 215
  • 448
5
votes
1 answer

Can a script update the Identity tab fields of Application Pool properties in IIS 6.0+

I am a developer and I have arrived at a solution to a webservice authentication problem that involved ensuring Kerberos was maintained because of multiple network hops. In short: A separate application pool for the virtual directory hosting the…
John Adams
  • 4,773
  • 25
  • 91
  • 131
5
votes
2 answers

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

I'm using the following code to authenticate via Kerberos. IntPtr logonToken = WindowsIdentity.GetCurrent().Token; string authenticationType = "WindowsAuthentication"; WindowsIdentity windowsIdentity = new WindowsIdentity(logonToken,…
Eric
  • 91
  • 1
  • 4
5
votes
1 answer

How to use System.Security.Principal.WindowsIdentity in .NET Core 2.1

How can we use WindowsIdentity in .NET Core 2.1? It was available in 2.0 .NET API Browser https://learn.microsoft.com/en-us/dotnet/api/?term=WindowsIdentity&view=netcore-2.0 WindowsIdentity is…
Rookian
  • 19,841
  • 28
  • 110
  • 180
5
votes
1 answer

Change the context of a thread to other user

A user triggers a event, thus the thread is in the context of said user. I iterate over all connected users and want to send them this event, but I want to use classic Authorization to determine if they should receive the event. Problem is the…
Anders
  • 17,306
  • 10
  • 76
  • 144
5
votes
2 answers

How to impersonate another user?

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…
DJPB
  • 5,429
  • 8
  • 30
  • 44
5
votes
2 answers

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

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…
TheWommies
  • 4,922
  • 11
  • 61
  • 79
1
2
3
13 14