Page 1 of 1 1
Topic Options
#194730 - 2009-07-13 09:08 PM User Account Copy
DStelz Offline
Getting the hang of it

Registered: 2007-01-26
Posts: 72
Loc: Green Bay, WI
I haven't had much luck finding anything on a copy function for LDAP objects. Is there a way to script a copy of a user object? I know that moving an object is possible, but I haven't seen much for copying.

Thanks ahead of time.

Top
#194734 - 2009-07-13 09:58 PM Re: User Account Copy [Re: DStelz]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Assuming you want to copy everything about a specific user to another user, you can get all the properties of the "source" user using this.
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=194576#Post194576

Then change the values that you need, and create a new user with the information already collected.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#194737 - 2009-07-13 10:32 PM Re: User Account Copy [Re: Gargoyle]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
An other link that might help.

http://techtasks.com/code/viewbookcode/1573

It's VB but I guess it is doable in kix also.

Literal translation. NOT TESTED!
 Code:
;This code copies the attributes in the Attrs array from an 
;existing object to a new one.
;------ SCRIPT CONFIGURATION ------
$arrAttrs = "department", "co", "title", "l", "c", "st"
$strParentDN = "<ParentContainer>" ;e.g. cn=Users,dc=rallencorp,dc=com
$strTemplateUser = "<TemplateUserName>" ;e.g. template-user-sales
$strNewUser = "<NewUserName>" ;e.g. jdoe
$strPassword = "<Password>"
;------ END CONFIGURATION ---------
     
$ADS_UF_NORMAL_ACCOUNT = 512 ;from ADS_USER_FLAG_ENUM
     
$objTemplate = GetObject( "LDAP://cn=" + $strTemplateUser + "," + $strParentDN )
$objParent = GetObject("LDAP://" + $strParentDN)
$objUser = $objParent.Create("user", "cn=" + $strNewUser)
     
$objUser.Put "sAMAccountName", $strNewUser
    
For Each $strAttr in $arrAttrs
	$objUser.Put $strAttr, $objTemplate.Get($strAttr)
Next
     
$objUser.SetInfo
$objUser.SetPassword($strPassword)
$objUser.SetInfo

$objUser.Put "userAccountControl", $ADS_UF_NORMAL_ACCOUNT
$objUser.AccountDisabled = FALSE
$objUser.SetInfo

? "Successfully created user"


Edited by Mart (2009-07-14 04:40 PM)
Edit Reason: Ripped out VB code and replaced it with a literal translation. You Bastas! :)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#194743 - 2009-07-14 03:01 AM Re: User Account Copy [Re: Mart]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
How can a MODERATOR post such NON KiXtart code - I thought you had to be an Admin to do that \:D
Top
#194745 - 2009-07-14 03:48 AM Re: User Account Copy [Re: NTDOC]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Yeah! Slacker! LOL
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#194760 - 2009-07-14 04:17 PM Re: User Account Copy [Re: Benny69]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Well, he IS a NEW mod, after all... \:D

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#194761 - 2009-07-14 04:28 PM Re: User Account Copy [Re: Glenn Barnas]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
LOL
My VBS skills really suck. Sure I can do a literal translation but I don't think that would be a working solution. Sadly I have no test environment.


Edited by Mart (2009-07-14 04:28 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#194776 - 2009-07-14 11:13 PM Re: User Account Copy [Re: Mart]
DStelz Offline
Getting the hang of it

Registered: 2007-01-26
Posts: 72
Loc: Green Bay, WI
This will help get started anyway. Thanks.
Top
#194780 - 2009-07-14 11:18 PM Re: User Account Copy [Re: DStelz]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
didn't glenn or allen make a proper translator?
I do remember that mine never really got finished...
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.063 seconds in which 0.027 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org