Esempio n. 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!!!");
            }
        }
Esempio n. 2
0
 extern static int NetLocalGroupAddMembers([MarshalAs(UnmanagedType.LPWStr)] string servername, [MarshalAs(UnmanagedType.LPWStr)] string groupname, int level, ref STRUCTS.LOCALGROUP_MEMBERS_INFO_3 buf, int totalentries);