#include "stdafx.h" // #include #include #include NET_API_STATUS GetDomainUsersSid(OUT PSID *ppSid); DWORD GetWellKnownName(IN DWORD dwRID, OUT WCHAR **pszName); /***************************************************************************** * * RemoveAllFromRDUsersGroup * * Removes all entries from "Remote Desktop Users" group * * ENTRY: * none * * * NOTES: * * * EXIT: * Returns: 0 if success, error code if failure * * * ****************************************************************************/ DWORD RemoveAllFromRDUsersGroup() { NET_API_STATUS Result,Result1; //Get "Remote Desktop Users" group name. //It may be different in different languages WCHAR *szRemoteGroupName = NULL; Result = GetWellKnownName(DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS, &szRemoteGroupName); if(Result == NERR_Success) { //Copy members of "Users" group to "Remote Desktop Users" group PLOCALGROUP_MEMBERS_INFO_0 plmi0 = NULL; DWORD entriesread = 0; DWORD totalentries = 0; DWORD_PTR resumehandle = 0; do { Result = NetLocalGroupGetMembers(NULL,szRemoteGroupName,0,(LPBYTE *)&plmi0, 1000,&entriesread, &totalentries,&resumehandle); if((Result == NERR_Success || Result == ERROR_MORE_DATA) && entriesread) { for(DWORD i=0;i