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);
}