开发者

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

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.

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(); ?

Anyone have any idea what could have changed to make this code stop working? the same user deleted th开发者_如何学Goe 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.

Sorry Everyone.

Cal-

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜