Page 1 of 1 1
Topic Options
#198686 - 2010-05-20 09:06 PM Adding a user to ldap group
5861king Offline
Fresh Scripter

Registered: 2006-09-28
Posts: 48
Loc: UK
Hi there can any help, I'm trying to add a newly created user to a domain group can anyone give me an example.
list below is the code i'm useing to create the account.

 Code:
Function CreateAccount($UserName, $FullName, $ADsPath)
	$OU = GetObject($ADsPath)
	$UserObj = $OU.Create("User", "cn=" + $FullName)
	$UserObj.Put("sAMAccountName", $UserName)
	$UserObj.Put("givenName", $fname) ;First Name
	$UserObj.Put("sn", $sname) ;Last Name(Surname)
	$UserObj.Put("displayName", $accountname)
	$UserObj.Put("description", $fname + " " + $sname) ;Description
	$UserObj.Put("mail", "$accountname@@server.co.uk") ;E-mail
	$UserObj.Put("wWWHomePage", "www.server.co.uk") ;Web page
	$UserObj.Put("userPrincipalName", "$accountname@@student.server.co.uk") ;userPrincipalName
	$UserObj.Put("scriptPath", "student.exe") ;Logon Script
	$UserObj.Put("department", $group)
	$UserObj.Put("title", $accountname)
	$UserObj.Put("homeDrive", "H:")
	$UserObj.Put("homeDirectory", "\\student.server.co.uk\home\" + $accountname)
	

	$userObj.SetPassword($accountname)    ;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
				
$accountname = "studenttest"
$group = "studenttest"
$fname = "studenttest"
$sname = "studenttest"
$username = "studenttest"
$fullnamename = "studenttest"



CreateAccount("$accountname", "$accountname", "LDAP://student.server.co.uk/OU=Standard Policy,DC=student,DC=server,DC=co,DC=uk")



Thnaks in advance

Glyn

Top
#198695 - 2010-05-21 10:16 AM Re: Adding a user to ldap group [Re: 5861king]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4945
Loc: Leatherhead, Surrey, UK
There are a few threads on the subject if you search around, try this one (and the referenced links) as a start: http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Board=8&Number=188283

You can also use the command line "NET GROUP" to manipulate groups.

Top
#198728 - 2010-05-27 09:44 AM Re: Adding a user to ldap group [Re: Richard H.]
5861king Offline
Fresh Scripter

Registered: 2006-09-28
Posts: 48
Loc: UK
 Originally Posted By: Richard H.
There are a few threads on the subject if you search around, try this one (and the referenced links) as a start: http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Board=8&Number=188283

You can also use the command line "NET GROUP" to manipulate groups.


Hi Richard H.

After alot of mucking around managed to get it working. So a big thanks for pointing me into the right direction.

Thanks

Glyn

Top
Page 1 of 1 1


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

Who's Online
0 registered and 35 anonymous users online.
Newest Members
thequeen, ameliaryan, shalomsalami, dkdssdk, Vroon
17639 Registered Users

Generated in 0.027 seconds in which 0.01 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