I want to prgrammatically apply some policy to user/group.
The related manual steps are:
Run gpedit.msc
Path is
Local Computer Policy\Cpmouter Configuration\Local Policies\User Rights Assignments\
In that "Log on Locally" policy I want to add the group \\machineName\GroupName
To achieve this I used GetAppliedGPOList API to enumarate GPOs.
This API returns SUCCESS but I dont get anything in GROUP_POLICY_OBJECT structure.
If I get GPO data in above structure, I can call some API to modify GPO data.
The code is:
// To get pSid of user call LookupAccountName API
char domain[256] = "";
DWORD domainSize = sizeof( domain );
DWORD size = 256;
PSID pSid;
pSid = (PSID) new BYTE[size];
if ( pSid == NULL)
return false;
memset(pSid, 0, size);
SID_NAME_USE eSidName;
DWORD err = LookupAccountName( NULL, "Administrator", pSid, &size, domain,
&domainSize, &eSidName );
if ( err == 0 )
err = GetLastError(); if ( IsValidSid( pSid ) == FALSE )
return false;
// With this pSid of user Call GetAppliedGPOList
GROUP_POLICY_OBJECT *pGPOList;
GUID guid =
{0x827D319E,0x6EAC,0x11D2,{0xA4,0xEA,0x00,0xC0,0x4F,0x79,0xF8,0x3A}};
DWORD error = GetAppliedGPOList( NULL, NULL,pSid,&guid, &pGPOList );
Is any other way to apply some policy to user/group WMI
Please Help!!

How to programmatically apply some policy to user/group?
King Gamo
This forum is dedicated to questions about the 2005 (Whidbey) release of Visual C++.
You can ask questions about WMI on the following MSDN newsgroup:
http://msdn.microsoft.com/newsgroups/default.aspx dg=microsoft.public.win32.programmer.wmi&lang=en&cr=US
Ronald Laeremans
Visual C++ team