Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ WindowsIdentity() [8/9]

unsafe System.Security.Principal.WindowsIdentity.WindowsIdentity ( string sUserPrincipalName)
inline

Definition at line 361 of file WindowsIdentity.cs.

362 : base(null, null, null, "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", "http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid")
363 {
364 checked
365 {
368 byte[] array = new byte[4] { 67, 76, 82, 0 };
369 Unsafe.SkipInit(out global::Interop.SspiCli.TOKEN_SOURCE SourceContext);
370 if (!global::Interop.Advapi32.AllocateLocallyUniqueId(out SourceContext.SourceIdentifier))
371 {
372 throw new SecurityException(new Win32Exception().Message);
373 }
374 SourceContext.SourceName = new byte[8];
375 Buffer.BlockCopy(array, 0, SourceContext.SourceName, 0, array.Length);
376 if (sUserPrincipalName == null)
377 {
378 throw new ArgumentNullException("sUserPrincipalName");
379 }
380 byte[] array2 = Encoding.Unicode.GetBytes(sUserPrincipalName);
381 if (array2.Length > 65535)
382 {
383 Array.Resize(ref array2, array2.Length & 0xFFFF);
384 }
385 int num = sizeof(global::Interop.SspiCli.KERB_S4U_LOGON) + array2.Length;
387 global::Interop.SspiCli.KERB_S4U_LOGON* ptr = unchecked((global::Interop.SspiCli.KERB_S4U_LOGON*)(void*)safeLocalAllocHandle.DangerousGetHandle());
388 ptr->MessageType = global::Interop.SspiCli.KERB_LOGON_SUBMIT_TYPE.KerbS4ULogon;
389 ptr->Flags = global::Interop.SspiCli.KerbS4uLogonFlags.None;
390 ptr->ClientUpn.Length = (ptr->ClientUpn.MaximumLength = (ushort)array2.Length);
391 IntPtr buffer = (IntPtr)(ptr + 1);
392 ptr->ClientUpn.Buffer = buffer;
393 Marshal.Copy(array2, 0, ptr->ClientUpn.Buffer, array2.Length);
394 ptr->ClientRealm.Length = (ptr->ClientRealm.MaximumLength = 0);
395 ptr->ClientRealm.Buffer = IntPtr.Zero;
396 ushort num2 = (ushort)array.Length;
398 Marshal.Copy(array, 0, safeLocalAllocHandle2.DangerousGetHandle(), array.Length);
399 global::Interop.Advapi32.LSA_STRING OriginName = new global::Interop.Advapi32.LSA_STRING(safeLocalAllocHandle2.DangerousGetHandle(), num2);
402 global::Interop.LUID LogonId;
404 global::Interop.SspiCli.QUOTA_LIMITS Quotas;
405 int SubStatus;
406 int num3 = global::Interop.SspiCli.LsaLogonUser(lsaHandle, ref OriginName, global::Interop.SspiCli.SECURITY_LOGON_TYPE.Network, authenticationPackage, safeLocalAllocHandle.DangerousGetHandle(), num, IntPtr.Zero, ref SourceContext, out ProfileBuffer, out ProfileBufferLength, out LogonId, out Token, out Quotas, out SubStatus);
407 if (num3 == -1073741714 && SubStatus < 0)
408 {
409 num3 = SubStatus;
410 }
411 if (num3 < 0)
412 {
414 }
415 if (SubStatus < 0)
416 {
418 }
419 ProfileBuffer?.Dispose();
421 }
422 }
static Microsoft.Win32.SafeHandles.SafeLocalAllocHandle LocalAlloc(int cb)
static void Copy(int[] source, int startIndex, IntPtr destination, int length)
Definition Marshal.cs:800
static Exception GetExceptionFromNtStatus(int status)
static unsafe int LookupAuthenticationPackage(SafeLsaHandle lsaHandle, string packageName)
static Encoding Unicode
Definition Encoding.cs:519

References System.Security.Principal.WindowsIdentity._safeTokenHandle, System.array, System.Buffer.BlockCopy(), System.buffer, System.Security.Principal.WindowsIdentity.ConnectToLsa(), System.Runtime.InteropServices.Marshal.Copy(), System.Runtime.Serialization.Dictionary, System.Security.Principal.WindowsIdentity.GetExceptionFromNtStatus(), Microsoft.Win32.SafeHandles.SafeLocalAllocHandle.LocalAlloc(), System.Security.Principal.WindowsIdentity.LookupAuthenticationPackage(), System.Security.Principal.WindowsIdentity.Token, System.Text.Encoding.Unicode, and System.IntPtr.Zero.