impersonation

LogonUser returns true for a wrong password

时光怂恿深爱的人放手 提交于 2021-02-20 19:02:29
问题 bool bRet=LogonUser(strUserName, L"", strPassword, LOGON32_LOGON_TYPE_NEW_CREDENTIALS, LOGON32_PROVIDER_WINNT50, &phToken) bRet always returns true even if I enter a wrong password when there is no domain. Is there any work around like if I enter a valid password it returns true and false for a wrong password when there is no domain. 回答1: I assume that by LOGON32_LOGON_TYPE_NEW_CREDENTIALS you actually mean LOGON32_LOGON_NEW_CREDENTIALS . In which case the behaviour is exactly as would be

CreateMutex fails after impersonation

余生颓废 提交于 2021-02-19 02:49:08
问题 Here's the code where I'me trying to impersonate a user and then create a mutex. The mutex is not getting created. I get ERROR_ACCESS_DENIED error. void Impersonate() { DWORD logonType = LOGON32_LOGON_INTERACTIVE; DWORD logonProvider = LOGON32_PROVIDER_DEFAULT; HANDLE userToken; HANDLE hMutex; DWORD err; LPSTR user = "zoom"; // the user I created myself on my machine. // It has Administrator privileges, and my account, // from which I start the app, is Admin too LPSTR password = "zoom"; LPSTR

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

Using RunImpersonated for an HttpClient call fails for a NUnit test, but works in Console

让人想犯罪 __ 提交于 2021-01-05 08:53:45
问题 I need to have my tests run as a testing account. To accomplish that I setup to the following code to create a handle into my testing account: SafeAccessTokenHandle testAccountHandle; bool returnValue = LogonUser("TestAccount", "myDom.net", "pass", 2, 0, out testAccountHandle); I can then make a call to load a URL: HttpResponseMessage response = null; await WindowsIdentity.RunImpersonated<Task>(testAccountHandle, async () => { var url = "https://accounts.google.com/.well-known/openid

File.Exists acts differently when access is denied to the file vs denied to the dir

℡╲_俬逩灬. 提交于 2020-08-19 07:45:05
问题 Based on the MSDN documentation of File.Exists , the File.Exists method should return false on any error, including the caller not having access to read the file. I would expect it to return false both when the file is set to FullControl denied to the user and FullControl denied to the user to the directory the file lives in. What I'm seeing is when the user has access to the directory, but not the file, File.Exists returns true ; however, if the user has no access to the directory, File

ASP.NET Core Identity impersonate specific user

淺唱寂寞╮ 提交于 2020-05-08 04:29:59
问题 Let's say I have the following roles: Admin User I want Admin role to impersonate specific user account with User role, but without knowing that specific user account's password. Admin should be able to impersonate any user from the application and be able to browse the application as the user himself. I found a link where this is actually implemented in ASP.NET MVC 4.6, but having a little headaches while converting this to Core version. Mostly because of the last line of code in the link

ASP.NET Core Identity impersonate specific user

淺唱寂寞╮ 提交于 2020-05-08 04:28:08
问题 Let's say I have the following roles: Admin User I want Admin role to impersonate specific user account with User role, but without knowing that specific user account's password. Admin should be able to impersonate any user from the application and be able to browse the application as the user himself. I found a link where this is actually implemented in ASP.NET MVC 4.6, but having a little headaches while converting this to Core version. Mostly because of the last line of code in the link

Impersonate User with Forms Authorization

☆樱花仙子☆ 提交于 2020-03-21 04:33:26
问题 I am using Forms Authorization to login to my web application against the active directory, what I am trying to do is when the user logins, impersonate that user. But I am running into a few problems, when I enable impersonate either via IIS or web.config I get a 500 error, here is that section of my web.config: <customErrors mode="Off"/> <authentication mode="Forms"> <forms name=".ADAuthCookie" loginUrl="~/Login/Index" timeout="45" slidingExpiration="false" protection="All" path="/" /> <