How to create Local User Account on Windows 2000 programatically?

I have to write a simple application that is supposed to create a user on the local machine. Any idea how we can do it on Windows 2000?? I have used ADSI routines. They dont work on all machines. Is there any other way to do it?? Some Win32 API etc?? Its urgent work. 500 points to whoever gives me the right solution. plz dont suggest using ADSI (directory services , i know how to do it using that).

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Use 'NetUserAdd()', e.g.

AddNewUser  (  
    LPWSTR  pwstrName,
    LPWSTR  pwstrPwd,
    LPWSTR  pwstrComment
    NET_API_STATUS              rc;
    USER_INFO_1                 ui1;

    wchar_t                     awcDomUsrName       [   LM20_DNLEN  +   LM20_UNLEN  +   1];
    wchar_t                     awcWkSta            [   MAX_COMPUTERNAME_LENGTH + 2];
    DWORD                       dwBufSiz            =   MAX_COMPUTERNAME_LENGTH + 1;

    ZeroMemory  (   &ui1,   sizeof (    USER_INFO_1));

    ui1.usri1_name          =   pwstrName;
    ui1.usri1_password      =   pwstrPwd;
    ui1.usri1_password_age  =   0;
    ui1.usri1_priv          =   USER_PRIV_USER;
    ui1.usri1_flags         =   UF_DONT_EXPIRE_PASSWD | UF_NORMAL_ACCOUNT | UF_SCRIPT;
    ui1.usri1_home_dir      =   L"";
    ui1.usri1_comment       =   pwstrComment;
    ui1.usri1_script_path   =   L"";

    GetComputerName (   awcWkSta,   &dwBufSiz);

    wsprintf    (   awcDomUsrName,  

    rc  =   NetUserAdd  (   NULL,   1,  ( LPBYTE) &ui1, &dwParmErr);

    return  (   rc);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sarah81Author Commented:
Thanks jkr, that was great help. And I found that my activeds solution wasnt wrong either. it was the just password that i was setting up wrong. but this NetUserAdd() is too fast than activeds this is cooool... thanks a lot :D
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.