Other methods for adding users without using net

Source: Internet
Author: User

1) Use APIs to add users. A source code section is provided.
# Include
# Include
# Include
# Pragma comment (lib, "netapi32 ")
Void usage ();
Int wmain (int argc, wchar_t * argv [])
{
USER_INFO_1 ui;
DWORD dwError = 0;
If (argc! = 3)
{
Usage ();
Return 0;
}
Ui. usri1_name = argv [1];
Ui. usrimo-password = argv [2];
Ui. usrisponpriv = USER_PRIV_USER;
Ui. usri#home_dir = NULL;
Ui. usrisponcomment = NULL;
Ui. usriw.flags = UF_SCRIPT;
Ui. usrisponscript_path = NULL;
If (NetUserAdd (NULL, 1, (LPBYTE) & ui, & dwError) = NERR_Success)
{
Printf ("User has been successfully added \ n ");
}
Else
{
Fwprintf (stderr, L "Add user % s Error! \ N ", argv [1]);
Return 1;
} Www.2cto.com
Wchar_t szAccountName [1, 100] = {0 };
Const unsigned short * name;
Name = (const unsigned short *) argv [1];
Wcscpy (szAccountName, name );
LOCALGROUP_MEMBERS_INFO_3 account;
Account. lgrmi3_domainandname = szAccountName;
If (NetLocalGroupAddMembers (NULL, L "Administrators", 3, (LPBYTE) & account, 1) = NERR_Success)
{
Printf ("Add to Administrators success. \ n ");
Return 0;
}
Else
{
Printf ("Add to Administrators Fail! \ N ");
Return 1;
}
}
Void usage ()
{
Printf ("===================================\ n ");
Printf ("==== AddUserByApi =======\ n ");
Printf ("Team: 90sec/www.90sec.org \ n ");
Printf ("Usage: Program username pass \ n ");
}
2) use Shell. Users to add Users. It calls the wscript. shell, Shell. Application, and Shell. LocalMachine components.
Js:
Var o = new ActiveXObject ("Shell. Users ");
Z = o. create ("90sec ");
Z. changePassword ("90sec ″,"")
Z. setting ("AccountType") = 3;
Vbs:
Set o = CreateObject ("Shell. Users ")
Set z = o. create ("90sec ")
Z. changePassword "90sec ″,""
Z. setting ("AccountType") = 3
From Shadow e

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.