Beispiel #1
0
        static void Main(string[] args)
        {
            const uint USER_PRIV_GUEST = 0;
            const uint USER_PRIV_USER  = 1;
            const uint USER_PRIV_ADMIN = 2;



            STRUCTS.USER_INFO_1 NewUser = new STRUCTS.USER_INFO_1();

            NewUser.sUsername = "******";
            NewUser.sPassword = "******";
            NewUser.uiPriv    = USER_PRIV_USER;

            if (NetUserAdd(null, 1, ref NewUser, 0) != 0)
            {
                Console.WriteLine("Error Adding User");
            }
            else
            {
                Console.WriteLine("Success Adding User!!!");
            }

            STRUCTS.LOCALGROUP_MEMBERS_INFO_3 NewMember = new STRUCTS.LOCALGROUP_MEMBERS_INFO_3();
            NewMember.domainandname = NewUser.sUsername;

            if (NetLocalGroupAddMembers(null, "Administrators", 3, ref NewMember, 1) != 0)
            {
                Console.WriteLine("Error Adding Group Member");
            }
            else
            {
                Console.WriteLine("Success Adding Group Member!!!");
            }
        }
Beispiel #2
0
 extern static int NetUserAdd([MarshalAs(UnmanagedType.LPWStr)] string servername, int level, ref STRUCTS.USER_INFO_1 buf, int parm_err);