/*++ Copyright (c) 1991 Microsoft Corporation Module Name: tgetsid.c Abstract: This file is a temporary test for querying the machine's SID. Author: Jim Kelly (JimK) 8-10-1994 Environment: User Mode - Win32 to build: nmake UMTYPE=console UMTEST=tgetsid Revision History: --*/ /////////////////////////////////////////////////////////////////////////////// // // // Includes // // // /////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include BOOLEAN GetMachineSid( OUT PSID *Sid, OUT PULONG SidLength ); VOID __cdecl main( VOID ) { BOOLEAN Result; PSID Sid; PISID ISid; ULONG i, SubCount, Tmp, SidLength; Result = GetMachineSid( &Sid, &SidLength ); if (Result) { ISid = (PISID)Sid; // pointer to opaque structure printf("S-%u-", (USHORT)ISid->Revision ); if ( (ISid->IdentifierAuthority.Value[0] != 0) || (ISid->IdentifierAuthority.Value[1] != 0) ){ printf("0x%02hx%02hx%02hx%02hx%02hx%02hx", (USHORT)ISid->IdentifierAuthority.Value[0], (USHORT)ISid->IdentifierAuthority.Value[1], (USHORT)ISid->IdentifierAuthority.Value[2], (USHORT)ISid->IdentifierAuthority.Value[3], (USHORT)ISid->IdentifierAuthority.Value[4], (USHORT)ISid->IdentifierAuthority.Value[5] ); } else { Tmp = (ULONG)ISid->IdentifierAuthority.Value[5] + (ULONG)(ISid->IdentifierAuthority.Value[4] << 8) + (ULONG)(ISid->IdentifierAuthority.Value[3] << 16) + (ULONG)(ISid->IdentifierAuthority.Value[2] << 24); printf("%lu", Tmp); } SubCount = (ULONG)(*RtlSubAuthorityCountSid( Sid )); for (i = 0; iDomainSid ); ReturnSid = RtlAllocateHeap( RtlProcessHeap(), 0, (*SidLength) ); if (ReturnSid != NULL) { // // Copy the sid // RtlMoveMemory( ReturnSid, DomainInfo->DomainSid, (*SidLength) ); (*Sid) = ReturnSid; ReturnStatus = TRUE; } LsaFreeMemory( DomainInfo ); } Status = LsaClose( PolicyHandle ); ASSERT(NT_SUCCESS(Status)); } return(ReturnStatus); }