Solved

Cannot remove Active Directory user

Posted on 2007-11-15
2
818 Views
Last Modified: 2008-02-01
I am trying to remove a user from Active Directory. adConn is my DirectoryEntry with admin rights. I keep getting an error that says that there is no such object on the server. I know the object is there because earlier in the program i can retrieve it as a search result. What am I doing wrong?

            'Locate the actual account in AD that is to be deleted
            Dim tempUser As DirectoryServices.DirectoryEntry = adConn.Children.Find("CN=John Smith", "Users")

            'Delete the account
            adConn.Children.Remove(tempUser)
            'Confirm
            adConn.CommitChanges()
0
Comment
Question by:swuit
2 Comments
 
LVL 16

Accepted Solution

by:
anoyes earned 50 total points
ID: 20295659
Have you tried continuing on with the tempUser LDAP path with your full domain?  Is "Users" a group, or an OU?
CN=John Smith,OU=Users,DC=domain,DC=com

I found a similar post on the ASP.net forums that might be worth taking a look at if you haven't seen it already.
http://forums.asp.net/t/1179504.aspx
0
 

Author Comment

by:swuit
ID: 20300681
I gave it the entire path. I used a DirectorySearcher and obtained the path from the result. I put the path in for adConn.Children.Find() to look for and it still tells me that there is nothing on the server.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question