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 567113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:02:55+00:00 2026-05-13T13:02:55+00:00

So I think I almost got it. I create my dummy account with one

  • 0

So I think I almost got it. I create my dummy account with one function, and wrote a second function to add it to the Remote Desktop group. Problem is, the Administrator account is the one logged in, so I am not sure how to specify what account to add to the group. Here is my code…

The user is being created properly…

 void AddRDPUser()
 {
     USER_INFO_1 ui;
     DWORD dwLevel = 1;
     DWORD dwError = 0;
     NET_API_STATUS nStatus;

     ui.usri1_name = L"BrettXFactor";
     ui.usri1_password = L"XfactorsServer96";
     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;

     nStatus = NetUserAdd(NULL, dwLevel, (LPBYTE)&ui, &dwError);
 }

But I dont know how to specify to add them to this group since they are not logged in. Any help would be appreciated

 void AddToGroup()
 {
     LOCALGROUP_MEMBERS_INFO_3 lgmi3;
     DWORD dwLevel = 3;
     DWORD totalEntries = 1;
     NET_API_STATUS nStatus;
     LPCWSTR TargetGroup = L"Remote Desktop Users";

     LPSTR sBuffer = NULL;
     memset(sBuffer, 0, 255);
     DWORD nBuffSize = sizeof(sBuffer);

     if(GetUserNameEx(NameDnsDomain, sBuffer, &nBuffSize)==0)
     {
         Msg("Failed to add User to Group\n");
         return;
     }

     LPWSTR user_name = (LPWSTR)sBuffer;
     lgmi3.lgrmi3_domainandname = user_name;

     nStatus = NetLocalGroupAddMembers(NULL, TargetGroup, 3,
         (LPBYTE)&lgmi3, totalEntries);
 }
  • 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-05-13T13:02:55+00:00Added an answer on May 13, 2026 at 1:02 pm

    No offense, but you don’t seem to know what you’re doing with the code at all. You’re not adding the current user to the target group; you’re adding the user you just created to it right? Then why are you calling GetUserNameEx? Just use the name of the new user:

    lgmi3.lgrmi3_domainandname = L"BrettXFactor";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think I almost got this. Say I want my app to send SMSs.
I think, in almost all cases user preference data may be stored in a
I am making an installer in java swing it almost completed only one thing
I think most people here understand the importance of fully automated builds. The problem
Hey everybody, got an interesting question I think. I've got a Silverlight3 application which
Say I've got two tables. One contains a list of items, and one contains
I ran Perl::Critic on one of my scripts, and got this message: Regular expression
I got this logic in a control to create a correct url for an
I'm using CSS to create a set of toggleable buttons. I'm almost there, but
I've got a real problem here. I have a page at: [page removed] and

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.