我创建了GPO
private void button5_Click(object sender, EventArgs e)
{
CreateAndLinkGPO(domain, "OU=Company,OU=Users,OU=Users,DC=Company.local,DC=net", "new_test_policy");
}
public void CreateAndLinkGPO(string strDomain, string strOU, string strGPOName)
{
GPM gpm = new GPMGMTLib.GPM();
IGPMConstants gpc = gpm.GetConstants();
IGPMDomain gpd = gpm.GetDomain(Environment.GetEnvironmentVariable("USERDNSDOMAIN"), "", gpc.UseAnyDC);
GPMSOM som = gpd.GetSOM(strOU);
GPMSearchCriteria gps = gpm.CreateSearchCriteria();
IGPMGPOCollection gpoc = gpd.SearchGPOs(gps);
IGPMGPO gpo = gpd.CreateGPO();
gpo.DisplayName = strGPOName;
som.CreateGPOLink(-1, gpo);
}
当我点击按钮时,我遇到错误“GPMSOM som = gpd.GetSOM(strOU);” - “HRESULT异常:0x8007202B” 我是域管理员。当我省略下面的行时,将创建策略,但仍会显示错误。 请帮忙,谢谢!