Page 2 of 2 <12
Topic Options
#184675 - 2008-01-18 08:21 AM Re: AD.User.Creation [Re: rossw]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
A yeah, I overlooked the .Put("Password")
Glad I could help \:\)

Top
#195555 - 2009-08-24 06:34 PM Re: AD.User.Creation [Re: Arend_]
5861king Offline
Fresh Scripter

Registered: 2006-09-28
Posts: 48
Loc: UK
 Originally Posted By: apronk
Please try this code, you've made a few errors, one of which is having "LoginScript" 2 times, LoginScript is actually "scriptPath", You need to use .SetInfo 2 times, one before you enable the account and set password. And some "" errors. here is the cleaned up code:
 Code:
CreateAccount("123456","Lastname Test", "LDAP://OU=test,OU=ouinformation,OU=nextleaveOU, dc=Domain ,dc=ad")

Function CreateAccount($UserName, $FullName, $ADsPath)
  $OU = GetObject($ADsPath)
  $UserObj = $OU.Create("User","cn="+$FullName)
  $UserObj.Put("sAMAccountName", $UserName)
  $UserObj.Put("givenName", "John") ;First Name
  $UserObj.Put("Initials", "Frank") ;Initials
  $UserObj.Put("sn", "Smith") ;Last Name(Surname)
  $UserObj.Put("displayName","Smith" + IIf("smith", ", ","") + "John" + IIf("Frank", " ", "") + "Frank") ;Display name
  $UserObj.Put("description", "Head Man in charge") ;Description
  $UserObj.Put("physicalDeliveryOfficeName","Wahington, DC") ;Office
  $UserObj.Put("telephoneNumber","222-555-5555");Telephone
  $UserObj.Put("mail","first_Last@company.com") ;E-mail
  $UserObj.Put("wWWHomePage","www.kixtart.org") ;Web page
  $UserObj.Put("userPrincipalName", "123456") ;userPrincipalName
  $UserObj.Put("scriptPath", "common.bat") ;Logon Script
  $UserObj.Put("Street", "1234 A Street, NW") ;Street
  $UserObj.Put("Password", "gensler")
  $UserObj.SetInfo

  ; Added Code
  $userObj.SetPassword("password")    ;Sets the password to "newpassword"
  $userObj.Put("pwdLastSet", 0)       ;User has to change the pw as soon as he/she logs in
  $userObj.AccountDisabled = 0        ;Enables the account
  $UserObj.SetInfo

  ; Objects cleanup
  $UserObj = 0
  $OU = 0
EndFunction



Hi ya.

Can you help when I run this code on Kix 4.60 I get an error message see below.

ERROR : expected ')'!
Script: H:\Folder Lock\Locker\Misc Stuff\Kix\AdminScriptEditor\ldap6.kix
Line : 36

This is what the line is
$UserObj = $OU.Create("User", "cn=" + $FullName)

can any one help me with this one, I would love to get this working.

Thanks

Glyn

Top
#195560 - 2009-08-24 10:32 PM Re: AD.User.Creation [Re: 5861king]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
5861king - Please do not HiJack old threads (lsat response was 4 years ago). Please start a new thread providing as many details as possible.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#195561 - 2009-08-24 10:39 PM Re: AD.User.Creation [Re: Gargoyle]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
A little more then 18 months Garg ;\)

But still, a new thread would be the way to go.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#195564 - 2009-08-24 11:39 PM Re: AD.User.Creation [Re: Mart]
5861king Offline
Fresh Scripter

Registered: 2006-09-28
Posts: 48
Loc: UK
sorry I'll post a new thread!!
Top
#195567 - 2009-08-24 11:48 PM Re: AD.User.Creation [Re: Mart]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
@Mart,
Oops looked at the Registration date of the last responder not the date of the last response. Oh well...
_________________________
Today is the tomorrow you worried about yesterday.

Top
Page 2 of 2 <12


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

Who's Online
2 registered (morganw, mole) and 414 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.056 seconds in which 0.023 seconds were spent on a total of 14 queries. Zlib compression enabled.

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