Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8704963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:14:19+00:00 2026-06-13T03:14:19+00:00

I receive user already exists error code when I try to create account programmaticaly

  • 0

I receive user already exists error code when I try to create account programmaticaly in windows 7, although user does not exists. What may be the cause of this problem ?

int wmain(int argc, wchar_t *argv[])
{
USER_INFO_1 ui;
ui.usri1_name =L"test-PC";
ui.usri1_password = L"12";
ui.usri1_priv = USER_PRIV_USER;
ui.usri1_home_dir = NULL;
ui.usri1_comment = NULL;
ui.usri1_flags = UF_SCRIPT;
ui.usri1_script_path = NULL;

addUser(NULL, ui);

while(true){}
return 0;

}

int addUser(LPWSTR servername, USER_INFO_1 ui) {
DWORD dwLevel = 1;
DWORD dwError = 0;

// Call the NetUserAdd function, specifying level 1.
NET_API_STATUS nStatus = NetUserAdd(servername, dwLevel, (LPBYTE)&ui, &dwError);

// If the call succeeds, inform the user.
// Nerr_Success error code is 0 independant from nerr_base
if (nStatus == NERR_Success) {
    fwprintf(stderr, L"ADD: User %s has been successfully added on %s\n", "1", "2");
    return 1;
}
//Nerr_base should be given since userexists is calculated by adding nerr_base to error code
else if((NERR_BASE + nStatus) == NERR_UserExists) 
    fprintf(stderr, "ADD: Account already exists: %d\n", nStatus);
else if(NERR_BASE + nStatus == ERROR_ACCESS_DENIED)
    fprintf(stderr, "ADD: Access Denied: %d\n", nStatus);
else if(NERR_BASE + nStatus == NERR_PasswordTooShort)
    fprintf(stderr, "ADD: Password is too short: %d\n", nStatus);
else if(NERR_BASE + nStatus == NERR_PasswordTooLong)
    fprintf(stderr, "ADD: Password is too long: %d\n", nStatus);
else
    fprintf(stderr, "ADD: A system error has occurred2: %d\n", nStatus);

return 0;

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:14:20+00:00Added an answer on June 13, 2026 at 3:14 am

    dwLevel parameter cannot be zero, it shall be in range 1-4, according to NetUserAdd MSDN documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The user does not want to receive the approval emails in Salesforce. Is there
I trying authenticate user in Spring Security application via oAuth. I'm already received token
How to receive broadcast when a user sends SMS from his Android phone? I
I am implementing a method that receive an authentication token from a user. Based
I am making a messaging application in which user can send or receive a
In my program, if a user tries to leave a page, he'll receive a
This is the standard scenario: User registers on the site User receives an account
I am trying to create a datapager usercontrol. This user control has one event
I am trying to receive user input and then put it into a list.
I have a Database say TestDatabase.I have already added an user under NTAuthority\SYSTEM(Role) Db_owner.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.