Error editing and deleting AD

B

Bryan Yeo

Got no problem adding an AD account using the LDAP connection, but error
when finding a record to edit:

DirectoryEntry entry = new DirectoryEntry("LDAP://MyDomainName,
DC=MyDomainName);
DirectoryEntries entriesChild= entry.Children;
DirectoryEntry entryCheck = entriesChild.Find("bryantest");
//Error: An invalid dn syntax has been specified

try
{
object ret = entry.Invoke("ChangePassword", new object[]{ OldPassword,
NewPassword });
entry.CommitChanges ();
}
catch(Exception excp)
{
throw(excp);
}


if ( entryCheck != null)
entriesChild.Remove(entryCheck);



Thanks
Bryan
 
W

Willy Denoyette [MVP]

Bryan Yeo said:
Got no problem adding an AD account using the LDAP connection, but error
when finding a record to edit:

DirectoryEntry entry = new DirectoryEntry("LDAP://MyDomainName,
DC=MyDomainName);
DirectoryEntries entriesChild= entry.Children;
DirectoryEntry entryCheck = entriesChild.Find("bryantest");

..... entriesChild.Find("cn=bryantest");

or better use the overload and supply the schemaclass name:

entriesChild.Find("cn=bryantest", "User");

Willy.
 
B

Bryan Yeo

Tried both and got this error: "There is no such object on the server."

Regards
Bryan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top