Answered by:
How to update group policy of domain user using IGroupPolicyObject?

Question
-
i am writing a program to update the group policies of the user for windows 10. I am able to update the local group policies of users in a workgroup using the IGroupPolicyObject2.OpenLocalMachineGPOForPrincipal(). But the same method will not work for domain users, in addition to that it causes a exception. I understand that in a workgroup, the group polices are stored locally and when in a domain it is stored in domain controller.
So to update the group policy i tried IGroupPolicyObject.OpenDSGPO(). It accepts 2 parameters- path and flag. The first parameter i passed "domain1/Users/user1" where "domain1" is the name of the domain, user1 is the domain user name. But i face an exception: "Value does not fall in the expected range"
Please suggest a way to update the group policy for the domain user using IGroupPolicyObject?
Note: i am aware of powershell to update the group policy but i am not going into it, since i am already using IGroupPolicyObject2.
- Edited by Nithin Vikraman Tuesday, May 17, 2016 8:18 AM
- Moved by DotNet Wang Wednesday, May 18, 2016 6:03 AM
Tuesday, May 17, 2016 8:15 AM
Answers
-
Hi Nithin,
>> But i face an exception: "Value does not fall in the expected range"
The first parameter is the values of path which specifies the Active Directory path of the object to open. If the path specifies a domain controller, the GPO is created on that DC. Otherwise, the system will select a DC on the caller's behalf. So you should set the path of your “domain1” not the username.
By the way, Group Policy on the domain controllers is updated every five minutes. For more information, please refer to Group Policy refresh interval for domain controllers
I hope it helps.
Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- Proposed as answer by Herro wongMicrosoft contingent staff Tuesday, May 31, 2016 7:17 AM
- Marked as answer by Xavier Xie-MSFT Wednesday, June 8, 2016 2:43 AM
Thursday, May 19, 2016 6:30 AM
All replies
-
Hi Nithin,
Based on your description, your case more related to Windows Desktop development, I will move your case to General Desktop Development issues forum for better support.
Best regards,
Kristin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.Wednesday, May 18, 2016 6:02 AM -
Hi Nithin,
>> But i face an exception: "Value does not fall in the expected range"
The first parameter is the values of path which specifies the Active Directory path of the object to open. If the path specifies a domain controller, the GPO is created on that DC. Otherwise, the system will select a DC on the caller's behalf. So you should set the path of your “domain1” not the username.
By the way, Group Policy on the domain controllers is updated every five minutes. For more information, please refer to Group Policy refresh interval for domain controllers
I hope it helps.
Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- Proposed as answer by Herro wongMicrosoft contingent staff Tuesday, May 31, 2016 7:17 AM
- Marked as answer by Xavier Xie-MSFT Wednesday, June 8, 2016 2:43 AM
Thursday, May 19, 2016 6:30 AM