NetUserGetInfo (netapi32)
Last changed: -78.187.200.203

.
Summary
TODO - a short description

C# Signature:

    [DllImport("Netapi32.dll", CharSet=CharSet.Unicode, ExactSpelling=true)]
    private extern static int NetUserGetInfo(
        [MarshalAs(UnmanagedType.LPWStr)] string ServerName,
        [MarshalAs(UnmanagedType.LPWStr)] string UserName,
        int level,
        out IntPtr BufPtr);  

VB Signature:

    Private Declare Function NetUserGetInfo Lib "Netapi32.dll" ( _
        ByVal ServerName As String, _
        ByVal UserName As String, _
        ByVal level As Integer, _
        ByRef BufPtr As IntPtr) As Integer

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

    public bool AccountGetFullName(string MachineName, string AccountName, ref string string FullName) {
        if (MachineName.Length == 0 ) {
            throw new ArgumentException("Machine Name is required");
        }
        if (AccountName.Length == 0 ) {
            throw new ArgumentException("Account Name is required");
        }
        try {
            // Create an new instance of the USER_INFO_1 struct
            USER_INFO_10 objUserInfo10 = new USER_INFO_10();
            IntPtr bufPtr; // because it's an OUT, we don't need to Alloc
            int lngReturn = NetUserGetInfo(_MachineName, _AccountName, 10, out bufPtr ) ;
            if (lngReturn == 0) {
                objUserInfo10 = (USER_INFO_10) Marshal.PtrToStructure(bufPtr, typeof(USER_INFO_10) );
                FullName = objUserInfo10.usri10_full_name;
            }
            NetApiBufferFree( bufPtr );
            bufPtr = IntPtr.Zero;
            if (lngReturn == 0 ) {
                return true;
            } else {
                //throw new System.ApplicationException("Could not get user's Full Name.");
                return false;
            }
        catch (Exception exp) {
            Debug.WriteLine("AccountGetFullName: " + exp.Message);
            return false;
        }
    }

Documentation