Hi,
I have c# .net windows application (vs2010). I am working on Active Directory GPO link and Unlink to an OU.
To link a GPO with an OU I used GPMGMT.lib and it is working below is the code
GPMGMTLib.GPM gpm =null;
gpm = new GPMGMTLib.GPM();
GPMGMTLib.GPMConstants gpc = (GPMConstants)gpm.GetConstants();
GPMGMTLib.GPMDomain gpd = (GPMDomain)gpm.GetDomain(strdomain, "", gpc.UseAnyDC);
GPMGMTLib.GPMSearchCriteria searchOBJ = gpm.CreateSearchCriteria();
searchOBJ.Add(gpc.SearchPropertyGPODisplayName, gpc.SearchOpEquals, strGPO);
GPMGMTLib.GPMGPOCollection objGPOlist = gpd.SearchGPOs(searchOBJ);
GPMGMTLib.GPMSOM gpSom = gpd.GetSOM(strOU);
gpSom.CreateGPOLink(-1, objGPOlist[1]);
But I am unable to delete link between GPO from an OU.
After searched in google got information saying add gpedit.dll which contains DeleteGPOLink method.
When I am trying to add reference it is giving me an error message saying
"A reference to C:\windows\system32\gpedit.dll could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component".
Could anyone suggest me how to unlink a GPO from an OU with an example.
Many Thanks in Advance.
Govind