copy active directory user 
Author Message
 copy active directory user

Hello.
 I am trying to write some code to copy an Active Directory user and
give
it a new name.  Supposedly the CopyTo() method of the DirectoryEntry can
do just this very thing, but when I run the following code, if I
uncomment the commented line (either one), I get a "Not Implemented"
exception.  The foreach loop works otherwise, so I know the objects are
being created.  I don't want to add a new user from scratch because
there
is already a user that has all of the right permissions set and I want
to
keep this simple.  Here is the code.

DirectoryEntry parent, olduser, newuser;

String strPath1="LDAP://CN=newuser,OU=pcs,DC=ucit,DC=uc,DC=edu";
String strPath2="LDAP://OU=pcs,DC=ucit,DC=uc,DC=edu";

olduser = new DirectoryEntry(strPath1);
parent = new DirectoryEntry(strPath2);

//newuser = olduser.CopyTo(parent,"newuser");
//olduser.CopyTo(parent);

foreach(DirectoryEntry objChildDE in parent.Children)
{
        lstDEs.Items.Add(objChildDE.Path);

Quote:
}      

Does anybody know why this would be happening?  
Thanks,
Daren

*** Sent via Developersdex http://www.*-*-*.com/ ***
Don't just participate in USENET...get rewarded for it!



Mon, 23 May 2005 02:09:05 GMT  
 copy active directory user
Daren, this is because the LDAP provider does not support the CopyTo method.
You will have to implement your own version of this if you want to use the
LDAP provider.

--
Greg Ewing [MVP]
http://www.claritycon.com/


Quote:

> Hello.
>  I am trying to write some code to copy an Active Directory user and
> give
> it a new name.  Supposedly the CopyTo() method of the DirectoryEntry can
> do just this very thing, but when I run the following code, if I
> uncomment the commented line (either one), I get a "Not Implemented"
> exception.  The foreach loop works otherwise, so I know the objects are
> being created.  I don't want to add a new user from scratch because
> there
> is already a user that has all of the right permissions set and I want
> to
> keep this simple.  Here is the code.

> DirectoryEntry parent, olduser, newuser;

> String strPath1="LDAP://CN=newuser,OU=pcs,DC=ucit,DC=uc,DC=edu";
> String strPath2="LDAP://OU=pcs,DC=ucit,DC=uc,DC=edu";

> olduser = new DirectoryEntry(strPath1);
> parent = new DirectoryEntry(strPath2);

> //newuser = olduser.CopyTo(parent,"newuser");
> //olduser.CopyTo(parent);

> foreach(DirectoryEntry objChildDE in parent.Children)
> {
> lstDEs.Items.Add(objChildDE.Path);
> }

> Does anybody know why this would be happening?
> Thanks,
> Daren

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Tue, 24 May 2005 00:23:37 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Add user into Active Directory using DirectoryServices and LDAP

2. Adding a User to Active Directory

3. Active Directory User Groups

4. Accesing Active Directory Users

5. how can i add a new user to Active Directory with C#

6. Disable a user in active directory use LDAP and directoryservices

7. Adding user to Active Directory using LDAP API

8. How do I create a new User Account in Active Directory

9. How to use CDOEXM to create Mail-Enabled users in Active Directory in C# (II)

10. Active Directory : Adding a user under LDAP

11. Get the postalAddress from an Active Directory User?

12. Create Active Directory User???

 

 
Powered by phpBB® Forum Software