Exemplo n.º 1
0
 /// <summary>
 /// Look up the account based on the SID.
 /// Non-static version of the method.
 /// </summary>
 /// <param name="server"></param>
 /// <param name="name"></param>
 /// <param name="domain"></param>
 /// <param name="peUse"></param>
 /// <returns></returns>
 public bool LookupAccount(
     string server,
     out string name,
     out string domain,
     out Interop.SID_NAME_USE peUse
     )
 {
     return(LookupAccountName(server, this, out name, out domain, out peUse));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Looks up the account based on the SID.
        /// Static version of the method.
        /// </summary>
        /// <param name="server"></param>
        /// <param name="sid"></param>
        /// <param name="name"></param>
        /// <param name="domain"></param>
        /// <param name="peUse"></param>
        /// <returns></returns>
        public static bool LookupAccountName(
            string server,
            Sid sid,
            out string name,
            out string domain,
            out Interop.SID_NAME_USE peUse
            )
        {
            // Init returns.
            name   = null;
            domain = null;
            peUse  = SID_NAME_USE.SidTypeUnknown;

            if (!sid.IsValid)
            {
                return(false);
            }
            return(Interop.Authorization.LookupAccountSid(server, sid.m_SidBuffer, out name, out domain, out peUse));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get the account name for the sid in dom\acct format.
        /// </summary>
        /// <param name="server"></param>
        /// <returns></returns>
        public string AccountName(
            string server
            )
        {
            Debug.Assert(!string.IsNullOrEmpty(server));

            string acctname = string.Empty;
            string dom      = string.Empty;
            string acct     = string.Empty;

            Interop.SID_NAME_USE peUse = SID_NAME_USE.SidTypeUnknown;
            if (LookupAccount(server, out acct, out dom, out peUse))
            {
                acctname = dom + @"\" + acct;
            }
            else
            {
                acctname = SidString;
            }

            return(acctname);
        }