DirectoryEntry.CopyTo Not Implemented!

  • Thread starter Thread starter Davie
  • Start date Start date
D

Davie

..NET 2.0

I was hoping the CopyTo method would be just what I needed to create a new
user in the same container and with the same properties as an existing one.
Rather than have to create the user and configure all the properties
manually. Something like the code below. However, when I try this I get a
not implemented exception.

Am I doing something wrong? If this isn't possible, could someone suggest a
way to create a new user based on an existing one please.

Dim newUsr As DirectoryEntry = copyFromUsr.CopyTo(copyFromUsr.Parent,
"newUserName")
 
I was hoping the CopyTo method would be just what I needed to create a new
user in the same container and with the same properties as an existing one.

You're not alone in this!
Am I doing something wrong? If this isn't possible, could someone suggest a
way to create a new user based on an existing one please.

Unfortunately, as you found out, the .CopyTo method is indeed *NOT*
implemented in the LDAP provider of the .NET framework. It is only
implemented in the NDS:// provider (Novell Directory Services).

Unfortunately, when talking to MS about this, they were not hinting at
all at implementing this anytime soon, citing there were numerous
potential problems with copying a given user to a new one.

Basically, all you can do is:

1) Create a new (blank) user
2) Loop over all or some of the source user's properties and set the
new user's properties to the same values (where those make sense)

There's no help from the S.DS namespace to do this, unfortunately.

Sorry I can't be of more help...

Marc
 
Back
Top