0

我创建 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”我是域管理员。当我省略下面的行时,会创建策略,但仍会显示错误。请帮忙,谢谢!

4

0 回答 0