public static extern bool LookupAccountSid(
     string lpSystemName,
     [MarshalAs(UnmanagedType.LPArray)] byte[] Sid,
     StringBuilder lpName,
     ref uint cchName,
     StringBuilder referencedDomainName,
     ref uint cchReferencedDomainName,
     out SidNameUse peUse);
 internal static extern bool LookupAccountName(
     [MarshalAs(UnmanagedType.LPWStr)]string lpSystemName,
     [MarshalAs(UnmanagedType.LPWStr)]string lpAccountName,
     IntPtr Sid,
     ref int cbSid,
     IntPtr ReferencedDomainName,
     ref int cchReferencedDomainName,
     out SidNameUse peUse);
 internal static extern bool LookupAccountSid(
     [MarshalAs(UnmanagedType.LPWStr)]string lpSystemName,
     IntPtr lpSid,
     IntPtr lpName, // string
     ref int cchName,
     IntPtr lpReferencedDomainName, // string
     ref int cchReferencedDomainName,
     out SidNameUse peUse);
			public static bool LookupAccountSid (
			string lpSystemName,
			[MarshalAs (UnmanagedType.LPArray)] byte [] Sid,
			StringBuilder lpName,
			ref uint cchName,
			StringBuilder ReferencedDomainName,
			ref uint cchReferencedDomainName,
			out SidNameUse peUse)
			{
				throw new System.NotImplementedException();
			}
Beispiel #5
0
 public static extern bool LookupAccountSid(string machineName, IntPtr pSid, StringBuilder szName, ref int nameSize, StringBuilder szDomain, ref int domainSize, out SidNameUse accountType);
 internal static extern bool LookupAccountSid(string lpSystemName, SafeSidBufferHandle lpSid, StringBuilder lpName,
                                              ref int cchName, StringBuilder lpReferencedDomainName, ref int cchReferencedDomainName, out SidNameUse peUse);
Beispiel #7
0
 private void GetNameAndUse(out string domain, out string name, out SidNameUse nameUse)
 {
     name = LsaPolicyHandle.LookupPolicyHandle.LookupName(this, out nameUse, out domain);
 }
Beispiel #8
0
 public static extern bool LookupAccountSid(string lpSystemName, [MarshalAs(UnmanagedType.LPArray)] byte[] sid, System.Text.StringBuilder lpName, ref uint cchName, System.Text.StringBuilder referencedDomainName, ref uint cchReferencedDomainName, out SidNameUse peUse);
Beispiel #9
0
 public static extern bool LookupAccountSid(
     /* [in]  */ [MarshalAs(UnmanagedType.LPTStr)] string systemName,
     /* [in]  */ IntPtr sid,
     /* [out] */ [MarshalAs(UnmanagedType.LPTStr)] StringBuilder name,
     /* [in]  */ ref int nameSize,
     /* [out] */ [MarshalAs(UnmanagedType.LPTStr)] StringBuilder domain,
     /* [in]  */ ref int domainSize,
     /* [out] */ out SidNameUse use);
Beispiel #10
0
 internal static extern bool PInvoke_LookupAccountSid(string lpSystemName, IntPtr Sid, string Name, out int cchName, string ReferencedDomainName, out int cchReferencedDomainName, out SidNameUse peUse);
        public Sid LookupSid(string name, out SidNameUse nameUse)
        {
            string domainName;

            return(this.LookupSid(name, out nameUse, out domainName));
        }
        public string LookupName(Sid sid, out SidNameUse nameUse)
        {
            string domainName;

            return(this.LookupName(sid, out nameUse, out domainName));
        }
Beispiel #13
0
 public static extern bool LookupAccountName(string systemName, StringBuilder name, byte[] bSid, ref int cbName, StringBuilder domainName, ref int cbDomainName, ref SidNameUse peUse);
 public static extern bool LookupAccountSid(string systemName, IntPtr sidHandle, StringBuilder name, ref uint nameSize, StringBuilder referencedDomainName, ref uint referencedDomainNameSize, out SidNameUse use);
Beispiel #15
0
        public static bool LookupAccountSid(string lpSystemName, IntPtr Sid, string Name, out int cchName, string ReferencedDomainName, out int cchReferencedDomainName, out SidNameUse peUse, [CallerMemberName] string callerName = "")
        {
            if (!PInvokeDebugger.LoggingEnabled)
            {
                return(PInvoke_LookupAccountSid(lpSystemName, Sid, Name, out cchName, ReferencedDomainName, out cchReferencedDomainName, out peUse));
            }

            bool             returnValue = PInvoke_LookupAccountSid(lpSystemName, Sid, Name, out cchName, ReferencedDomainName, out cchReferencedDomainName, out peUse);
            PInvokeDebugInfo debugInfo   = PInvokeDebugInfo.TraceDebugInfo(
                ModuleName,
                nameof(LookupAccountSid),
                callerName,
                returnValue,
                false,
                nameof(lpSystemName), lpSystemName,
                nameof(Sid), Sid,
                nameof(Name), Name,
                nameof(cchName), cchName,
                nameof(ReferencedDomainName), ReferencedDomainName,
                nameof(cchReferencedDomainName), cchReferencedDomainName,
                nameof(peUse), peUse
                );

            PInvokeDebugger.SafeCapture(debugInfo);
            return(returnValue);
        }
Beispiel #16
0
 public static extern bool LookupAccountName(string machineName, string accountName, IntPtr pSid, ref int sidLen, StringBuilder szDomain, ref int domainSize, out SidNameUse accountType);
        public Sid LookupSid(string name, out SidNameUse nameUse, out string domainName)
        {
            NtStatus      status;
            UnicodeString nameStr;
            IntPtr        referencedDomains;
            IntPtr        sids;

            nameStr = new UnicodeString(name);

            try
            {
                if ((status = Win32.LsaLookupNames2(
                         this,
                         0,
                         1,
                         new UnicodeString[] { nameStr },
                         out referencedDomains,
                         out sids
                         )) >= NtStatus.Error)
                {
                    if (status == NtStatus.NoneMapped)
                    {
                        nameUse    = SidNameUse.Unknown;
                        domainName = null;
                        return(null);
                    }

                    Win32.Throw(status);
                }
            }
            finally
            {
                nameStr.Dispose();
            }

            using (var referencedDomainsAlloc = new LsaMemoryAlloc(referencedDomains))
                using (var sidsAlloc = new LsaMemoryAlloc(sids))
                {
                    LsaTranslatedSid2 translatedSid = sidsAlloc.ReadStruct <LsaTranslatedSid2>();

                    nameUse = translatedSid.Use;

                    if (nameUse == SidNameUse.Invalid || nameUse == SidNameUse.Unknown)
                    {
                        domainName = null;

                        return(null);
                    }

                    if (translatedSid.DomainIndex != -1)
                    {
                        LsaReferencedDomainList domains    = referencedDomainsAlloc.ReadStruct <LsaReferencedDomainList>();
                        MemoryRegion            trustArray = new MemoryRegion(domains.Domains);
                        LsaTrustInformation     trustInfo  = trustArray.ReadStruct <LsaTrustInformation>(translatedSid.DomainIndex);

                        domainName = trustInfo.Name.Read();
                    }
                    else
                    {
                        domainName = null;
                    }

                    return(new Sid(translatedSid.Sid));
                }
        }
 public static extern bool LookupAccountSid(string systemName, IntPtr sidHandle, StringBuilder name, ref uint nameSize, StringBuilder referencedDomainName, ref uint referencedDomainNameSize, out SidNameUse use);