Guid和NativeGuid引发COMException

时间:2019-02-11 06:08:48

标签: c# active-directory

我正在尝试在Active Directory的根目录中创建新的OU,但是它会不断抛出异常。是否可能是因为我要成为管理员?

链接到屏幕截图: https://drive.google.com/file/d/1ERLT64PIWrCoECzq0GGTdwMR1mQqln9w/view?usp=sharing

`
public void CreateGroup()
        {   
            DirectoryEntry dir = new DirectoryEntry("LDAP://ENCOTEC");
            DirectorySearcher search = new DirectorySearcher(dir);
            search.Filter = "(OU=IT System)";
            SearchResult it = search.FindOne();
            if (it == null)
            {
                DirectoryEntry newEntry = dir.Children.Add("OU=IT System", "organizationalUnit");
                dir.CommitChanges();
            }
`

0 个答案:

没有答案