简体   繁体   English

c#Active Directory…在根目录下创建OU时很奇怪

[英]c# Active Directory… weirdness when creating a OU just under the root

So, I've run thi scode a dozen times and it worked, now it's not working. 因此,我已经运行了十次该编码,并且该编码正常工作,但现在不起作用。 I'm assuming its some kind of permission on the ad server for the account that's logged in, but the behavior is still puzzling. 我假设已登录帐户在广告服务器上具有某种权限,但这种行为仍然令人困惑。

here is the code 这是代码

public JCDCDirectoryEntry CreateOrgUnit( string organizationalUnit, string description, ADS_GROUP_TYPE type )
{
    log.Debug( GetMethodNameAndParms() + " - in" );

    // Bind to the domain that this user is currently connected to.
    DirectoryEntry g = ADEntry.Children.Add( "ou=" + organizationalUnit, "organizationalUnit" );
    g.Properties[ "description" ].Value = description;

    // Commit the new organizationalUnit to the directory.
    g.CommitChanges();
    JCDCDirectoryEntry newOrgUnit = new JCDCDirectoryEntry( g, BuildType.distinguishedName, ADManager );

    g.Close();

    return newOrgUnit;
}

this part just does a search for the OU "Centers" by name 这部分只是按名称搜索OU“中心”

JCDCDirectoryEntry newOrgUnit = new JCDCDirectoryEntry( g, BuildType.distinguishedName, ADManager );

everything runs with no errors till it hits that line, then that line says no such object exists on the server. 一切正常,直到命中该行为止,然后该行表明服务器上不存在此类对象。

I go look in the LDAP browser,and yes, the Centers OU does not exist. 我去看一下LDAP浏览器,是的,Centers OU不存在。

But if it's a permissions thing, why does it not throw and error on this bit... 但是,如果这是权限的事情,为什么它不抛出错误呢?

DirectoryEntry g = ADEntry.Children.Add( "ou=" + organizationalUnit, "organizationalUnit" );
g.Properties[ "description" ].Value = description;

// Commit the new organizationalUnit to the directory.
g.CommitChanges();

Shouldn't it throw an error on CommitChanges(); 它不应该在CommitChanges()上引发错误吗? ?

Anyone have any idea what could have changed to make this code stop working? 任何人都知道为了使此代码停止工作可能进行了哪些更改? the same user deleted the tree, so it's got permissions to do at least somethings... 相同的用户删除了该树,因此它至少有权执行某些操作...

I used this same code, at least a dozen times testing earlier on this same domain, say a month ago. 我使用了相同的代码,至少一个月前在相同的域上进行了至少十多次测试。

Any help or hint is greatly appreciated. 任何帮助或提示,我们将不胜感激。

Sigh, 叹,

I rebooted my machine and it started working agian. 我重启了机器,开始使用agian。

Sorry Everyone. 对不起,大家。

Cal- Cal-

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我们在asp.net c#中的活动目录中创建用户时,如何在活动目录中嵌套OU时,如何给出路径来识别OU? - How to give path to identify OU when we have nested OU's in active directory while creating a user in active directory in asp.net c#? C#在Active Directory中创建OU - C# Create OU in Active Directory C#Active Directory,登录特定OU - C# Active Directory, Login in a specific OU C#和Active Directory:测试OU是否存在 - C# and Active Directory : test if an OU exist 尝试在Active Directory C#中委派OU的控件时,出现DirectoryServicesCOMException“发生操作错误” - DirectoryServicesCOMException “operations error occurred” when trying to delegate control for OU in Active directory C# 尝试从 Active Directory 检索和 OU,然后使用 C# 中的目录条目在 OU 上设置新属性 - Trying to Retrieve and OU from Active Directory, then set new properties on an OU using a Directory Entry in C# 使用C#在Active Directory中获取用户的父OU - Get parent OU of user in Active Directory using C# 使用具有层次结构的c#从活动目录获取OU列表 - Get OU list from active directory using c# with hierarchy 如何在 Active Directory C# 中的指定 ou 下面列出 ous(组织单位) - How can I list ous (organizational units) below a specified ou in Active Directory C# 在 C# 中创建密码为 Active Directory 的用户 - Creating Active Directory user with password in C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM