LogonUser error with error code: 1326

Please help me with this? I tried to log into the .microsoftonline.com portal with the necessary credentials, but I got this error. Is my url wrong or what? Because I'm trying to personalize and give the role to the user. Thanks, and btw, I'm new here, please forgive me for how I post my problem. Please see Comment for error.

class SecurityHelpers { private SecurityHelpers() { } [DllImport("advapi32.dll", SetLastError = true)] private static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken); [DllImport("kernel32.dll", CharSet = CharSet.Auto)] private extern static bool CloseHandle(IntPtr handle); public static WindowsIdentity CreateIdentity( string userName, string domain, string password) { IntPtr tokenHandle = new IntPtr(0); const int LOGON32_PROVIDER_DEFAULT = 0; const int LOGON32_LOGON_NETWORK_CLEARTEXT = 3; tokenHandle = IntPtr.Zero; bool returnValue = LogonUser(userName, domain, password, LOGON32_LOGON_NETWORK_CLEARTEXT, LOGON32_PROVIDER_DEFAULT, ref tokenHandle); if (false == returnValue) { int ret = Marshal.GetLastWin32Error(); // THIS WHERE THE ERROR IS - "LogonUser failed with error code: 1326" throw new Exception("LogonUser failed with error code: " + ret); } WindowsIdentity id = new WindowsIdentity(tokenHandle); CloseHandle(tokenHandle); return id; } } 
+4
source share
2 answers

Perhaps xp_cmdshell runs through a proxy account. Check if the proxy account has credentials.

In Object Explorer, navigate to:

 Security > Credentials > ##xp_cmdshell_proxy_account## 

Also check to see if the user has sys.xp_cmdshell execute sys.xp_cmdshell

In Object Explorer, navigate to:

 Databases > System Databases > master > Security > Users > [user] > Securables 

SQL to resolve:

 use [master] grant execute on xp_cmdshell to [domain\user]; 
+1
source

userName , domain a password must be passed as Windows Wide Character or Windows Unicode . Make sure you transfer them in the correct format.

0
source

Source: https://habr.com/ru/post/1488396/


All Articles