windows-identity

can WindowsIdentity.GetCurrent() return null?

女生的网名这么多〃 提交于 2019-12-05 00:28:48
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? nitzanms Using ILSpy, you can look at a de-compiled version of GetCurrent and GetCurrentInternal , which GetCurrent calls. The result is: GetCurrent: public static WindowsIdentity GetCurrent() { return WindowsIdentity.GetCurrentInternal(TokenAccessLevels

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

喜你入骨 提交于 2019-12-04 09:51:33
问题 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 and no cookie was found in the context. Here is some info about our setup: • We‘re using built-in Windows Identity Framework with .NET Framework 4.5.1 • The problem is almost always associated with changing from RelyingParty#X over to RelyingParty#Y

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

混江龙づ霸主 提交于 2019-12-04 05:07:26
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 code is called via AJAX. When I hit this code, it works about 2/3 of the time, but 1/3 of the time, I

WIF- ID1014: The signature is not valid. The data may have been tampered with

旧城冷巷雨未停 提交于 2019-12-03 06:53:40
I've been using WIF to authenticate our new website, the STS is based upon the starter-sts implementation. To enable this to work correctly on out load balanced environment I've used the following in the global.asax to override the default certificate behaviour. void onServiceConfigurationCreated(object sender, ServiceConfigurationCreatedEventArgs e) { List<CookieTransform> sessionTransforms = new List<CookieTransform>(new CookieTransform[] { new DeflateCookieTransform(), new RsaEncryptionCookieTransform(e.ServiceConfiguration.ServiceCertificate), new RsaSignatureCookieTransform(e

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

匆匆过客 提交于 2019-12-03 03:31:41
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 and no cookie was found in the context. Here is some info about our setup: • We‘re using built-in Windows Identity Framework with .NET Framework 4.5.1 • The problem is almost always associated with changing from RelyingParty#X over to RelyingParty#Y ( e.g. the moment user clicks the RP#Y he‘s SIGNED OUT without asking for it ) – when he logs in

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

倖福魔咒の 提交于 2019-12-01 05:25:09
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 := TRegistry.Create(KEY_WRITE); try Registry.Lazywrite := false; Registry.RootKey := HKEY_LOCAL_MACHINE; // Registry.RootKey := HKEY_CURRENT_USER; if CheckForWinNT = true then Begin if not Registry.OpenKeyReadOnly('\Software\Microsoft\Windows NT\CurrentVersion') then showmessagE('cant open'); end else Registry.OpenKeyReadOnly('\Software\Microsoft\Windows\CurrentVersion'); str := Registry

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

谁说我不能喝 提交于 2019-12-01 02:27:18
问题 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 := TRegistry.Create(KEY_WRITE); try Registry.Lazywrite := false; Registry.RootKey := HKEY_LOCAL_MACHINE; // Registry.RootKey := HKEY_CURRENT_USER; if CheckForWinNT = true then Begin if not Registry.OpenKeyReadOnly('\Software\Microsoft\Windows NT\CurrentVersion') then showmessagE('cant

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

痞子三分冷 提交于 2019-11-30 15:35:34
I enabled impersonation and windows authentiaction. <authentication mode="Windows" /> <identity impersonate="true" userName="name" password="passord"/> But Thread.CurrentPrincipal.Identity.Name returnes the name of authenticated user and WindowsIdentity.GetCurrent() returns impersonated identity. Shouldn't these identities be the same? And under wich credentials does the code run in this case? Andrei Zubov As far as I can understand the Thread.CurrentPrincipal contains the information of conditions the thread has been started with, including the WindowsIdentity. That's why Thread

MVC3 Windows Authentication override User.Identity

佐手、 提交于 2019-11-30 03:54:42
I am building a intranet application using MVC3 with a MSSQL backend. I have authentication and roles (through a custom roles provider) working properly. What I am trying to do now is overriding User.Identity to allow for items like User.Identity.FirstName. But I cannot find any code that will show me how do this in WindowsIdentity I have tried writing a custom provider: public class CPrincipal : WindowsPrincipal { UserDAL userDAL = new UserDAL(); public CPrincipal(WindowsIdentity identity) : base(identity) { userInfo = userDAL.GetUserProfile(identity.Name.Split('\\')[1]); this.identity =

How can I retrieve all the roles (groups) a user is a member of?

柔情痞子 提交于 2019-11-29 16:12:32
问题 Is there a way to get a list of roles a Windows authenticated user is in, without explicitly checking by WindowsPrincipal.IsInRole method? 回答1: WindowsPrincipal.IsInRole just checks if the user is a member of the group with that name; a Windows Group is a Role. You can get a list of the groups that a user is a member of from the WindowsIdentity.Groups property. You can get WindowsIdentity from your WindowsPrincipal : WindowsIdentity identity = WindowsPrincipal.Identity as WindowsIdentity; or