Novell Home

Set a password for a new user

From Developer Community

This snippet uses the NWDir UCX component to set an eDir user's password in PHP. See the NScript documentation for more details.

Sample Code

$uname = 'user' //set the password for this user
$pass = 'password'

$dir = new UCS('UCX:NWDir') or die ('Unable to create the NWDir object');
$fullname = "NDS:\\\\AUTHTREE\\Novell\\"; // put your treename + container inhere
$dir->fullName = $fullname;

$UserName = "admin"; // user name with enough rights, should be in container specified above
$Password = "novell"; // password... 
$dir->login($UserName, $Password) or die ('Could not login');

$fullname = $dir->fullName;
$name = $fullname.$uname;  
$entry =$dir->findEntry($name) or die ('Could not find user');
$entry->setPassword($pass) or die ('Could not set password');
echo "$name was created successfully";

--Paul Jones

Novell® Making IT Work As One

© 2008 Novell, Inc. All Rights Reserved.