public static extern /*WinStatusCodes */ uint LsaLogonUser( [In] IntPtr LsaHandle, [In] ref LSA_STRING OriginName, [In] SECURITY_LOGON_TYPE LogonType, [In] UInt32 AuthenticationPackage, [In] IntPtr AuthenticationInformation, [In] UInt32 AuthenticationInformationLength, [In] PTOKEN_GROUPS LocalGroups, [In] ref TOKEN_SOURCE SourceContext, [Out] /*PVOID*/ out IntPtr ProfileBuffer, [Out] out UInt32 ProfileBufferLength, [Out] out Int64 LogonId, [Out] out IntPtr Token, [Out] out QUOTA_LIMITS Quotas, [Out] out /*WinStatusCodes */ uint SubStatus );
public void LsaLogonUser_Success() { var connectStatus = LsaConnectUntrusted(out var lsaHande); var lsaString = new LSA_STRING("Kerberos"); var lsaStatus = LsaLookupAuthenticationPackage(lsaHande, ref lsaString, out var authenticationPackage); AllocateLocallyUniqueId(out var srcLuid); var tokenSource = new TOKEN_SOURCE { SourceName = "foobar12".ToCharArray(), SourceIdentifier = srcLuid }; var lsaOriginName = new LSA_STRING("Kerberos"); var kerb = new KERB_INTERACTIVE_LOGON() { MessageType = KERB_LOGON_SUBMIT_TYPE.KerbInteractiveLogon, LogonDomainName = new UNICODE_STRING("eu"), UserName = new UNICODE_STRING("martijn"), Password = new UNICODE_STRING("Unisys!1") }; IntPtr info = (IntPtr)1024;// Marshal.SizeOf(kerb); Marshal.StructureToPtr(kerb, info, false); PTOKEN_GROUPS groups = new PTOKEN_GROUPS() { GroupCount = 0 }; IntPtr profileBuffer = IntPtr.Zero; UInt32 profileBufferLength = 0; Int64 logonId; IntPtr token = IntPtr.Zero; UInt32 subStatus; QUOTA_LIMITS quotas; var logon = LsaLogonUser(lsaHande, ref lsaOriginName, SECURITY_LOGON_TYPE.Interactive, authenticationPackage, info, 1024, groups, ref tokenSource, out profileBuffer, out profileBufferLength, out logonId, out token, out quotas, out subStatus); }