Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy

Search Results for "LookupAccountSid" in [All]

advapi32

.

Also, the example given below is mildly incompatible with the example given for LookupAccountSid() on this site.

.

    errorReturn = LookupAccountSid(null, pSid, _account, ref _accounLength, _domain, ref _domainLength, out _sidNameUse);

.

        Console.WriteLine("LookupAccountSid: {0}", Marshal.GetLastWin32Error());

.
Summary
The LookupAccountSid function accepts a security identifier (SID) as input. It retrieves the name of the account for this SID and the name of the first domain on which this SID is found.
.

static extern bool LookupAccountSid(

.

    Declare Function LookupAccountSid Lib "advapi32.dll" _

.

    Alias "LookupAccountSidA" ( _

.

The LookupAccountSid function attempts to find a name for the specified SID by first checking a list of well-known SIDs. If the supplied SID does not correspond to a well-known SID, the function checks built-in and administratively defined local accounts. Next, the function checks the primary domain. Security identifiers not recognized by the primary domain are checked against the trusted domains that correspond to their SID prefixes.

.

If the function cannot find an account name for the SID, the LookupAccountSid function fails and GetLastError returns ERROR_NONE_MAPPED. This can occur if a network time-out prevents the function from finding the name. It also occurs for SIDs that have no corresponding account name, such as a logon SID that identifies a logon session.

.

In addition to looking up SIDs for local accounts, local domain accounts, and explicitly trusted domain accounts, LookupAccountSid can look up SIDs for any account in any domain in the forest, including SIDs that appear only in the SIDhistory field of an account in the forest. The SIDhistory field stores former SIDs of an account that has been moved from another domain. To look up a SID, LookupAccountSid queries the global catalog of the forest.

.

    static extern bool LookupAccountSid (

.

      if (!LookupAccountSid(null,Sid,name,ref cchName,referencedDomainName,ref cchReferencedDomainName,out sidUse))

.

      if (!LookupAccountSid(null,Sid,name,ref cchName,referencedDomainName,ref cchReferencedDomainName,out sidUse))

.

    Private Shared Function MyLookupAccountSid(ByRef i_Sid() As Byte) As String

.

        l_Result = LookupAccountSid(Nothing, i_Sid, l_UserName, l_UserNameLength, l_Domain, l_DomainLength, l_use)

.

        l_Result = LookupAccountSid(Nothing, i_Sid, l_UserName, l_UserNameLength, l_Domain, l_DomainLength, l_use)

.

But SecurityIdentifier.Translate() method works only on domain accounts. To resolve local SIDs into account name you can use Win32 API function LookupAccountSid().

.
Documentation
[LookupAccountSid] on MSDN

netapi32

.

    static extern bool LookupAccountSid(

.

        if (!LookupAccountSid(null, baSid, sbName, ref uiName, sbReferencedDomainName, ref uiReferencedDomainNameCount, out eUse))

.

        static extern bool LookupAccountSid(

.

            if (!LookupAccountSid(null, baSid, sbName, ref uiName, sbReferencedDomainName, ref uiReferencedDomainNameCount, out eUse))

.

        static extern bool LookupAccountSid(

.

            if (!LookupAccountSid(null, baSid, sbName, ref uiName, sbReferencedDomainName, ref uiReferencedDomainNameCount, out eUse))

Enums

.

    ///The system function, LookupAccountSID, failed

.

    [Description("The system function, LookupAccountSID, failed")]

.

    '''The system function, LookupAccountSID, failed

.

    <Description("The system function, LookupAccountSID, failed")> _

.
Summary

Constants

.

        /// The system function, LookupAccountSID, failed


 
Access PInvoke.net directly from VS: