Jaunty Jackalope is On

Yesterday Jaunty is really released. Now let's try it on and get the fastest Ubuntu boot with ext4.

welcome to utux-utux

The place where you can get any news, tipsn and tutorials about linux. I'cant explain any further informations about this site. Just open the tux image on the left side. ^_^

Add Mass of Clarkconnect Users From Text File

Don't even try to add user from shell with useradd in Clarkconnect. Why? It's because the linux user database is also used for the ldap database (see previous posting of me). If you do it, even the user is registered to linux user but the user won't be able login with his ldap account. You can only add the user within webconfig. The fact is database for linux user and ldap user is different.
The problem begin here. What about adding mass of users, for me 6000, users to the ldap systems. I've thoughted we can easily solve the problem with shell script. Right? But that's actually wrong. So what we gonna do now?
After look after Clarkconnect forum, I founded it. A script to add mas of users automatically from text file. But don't worry, this time the ldap user also would be made.

First, made a text file for username named user_list.txt and put it to /tmp folder. Form for the text is:
USERNAME1:UID:PASSWORD:FIRSTNAME LASTNAME
USERNAME2:UID:PASSWORD:FIRSTNAME LASTNAME
USERNAME3:UID:PASSWORD:FIRSTNAME LASTNAME
....etc

You can easily convert your database to .csv file type and replace the commas (,) with (:).

Then make the main script named user.php. This script can you put within your home folder.
#!/usr/webconfig/bin/php -q

///////////////////////////////////////////////////////////////////////////////
//
// Copyright 2003-2007 Point Clark Networks.
//
///////////////////////////////////////////////////////////////////////////////
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
///////////////////////////////////////////////////////////////////////////////

/*****************************************************************************/
/* D E P E N D E N C I E S */
/*****************************************************************************/

require_once("/var/webconfig/api/User.class.php");
require_once("/var/webconfig/api/File.class.php");
require_once("/var/webconfig/api/UserManager.class.php");
error_reporting(0);

$file = new File("/tmp/user_list.txt");
if (!$file->Exists()) {
echo "File not found.\n";
return 1;
}

$lines = $file->GetContentsAsArray();
foreach ($lines as $line) {
$userinfo = array(
'dn' => null,
'sn' => null,
'cn' => null,
'givenName' => null,
'uid' => null,
'title' => null,
'o' => null,
'ou' => null,
'roomNumber' => null,
'street' => null,
'postOfficeBox' => null,
'postalCode' => null,
'l' => null,
'st' => null,
'c' => null,
'telephoneNumber' => null,
'facsimileTelephoneNumber' => null,
'kolabFreeBusyFuture' => 60,
'pol' => array('anyone' => 4),
'alias' => '',
'delegate' => '',
'cyrus-userquota' => '',
'kolabDeleteflag' => false,
'pcnFTPPasswordFlag' => true,
'pcnMailPasswordFlag' => true,
'pcnPPTPPasswordFlag' => true,
'pcnProxyPasswordFlag' => true,
'pcnWebconfigPasswordFlag' => true,
'pcnSambaPasswordFlag' => true,
'pcnWebPasswordFlag' => true,
);

$profile = explode(":",$line);
$user = new User($profile[0]);
if ($user->IsValidUsername($profile[0])) {
$username = strtolower($profile[0]);
$userinfo['uid'] = $username;
$userinfo['password'] = $profile[2];
$userinfo['verify'] = $profile[2];
}else{
echo "Invalid username (" . $profile[0] . ").";
return 1;
}
// protect root
if ($username == 'root') {
echo "Skipping root account...\n";
continue;
}

// protect system account
if ((int)$profile[1] < 1000) {
echo "Skipping system account (UID < 1000)...\n";
continue;
}

list($first, $last) = explode(" ", $profile[3]);

if ($user->IsValidFirstName($first)) {
$userinfo['givenName'] = $first;
} else {
echo "Invalid first name (" . $first . ").";
return 1;
}
if ($user->IsValidLastName($last)) {
$userinfo['sn'] = $last;
} else {
echo "Invalid last name (" . $last . ").";
return 1;
}

try {
$user->Add($userinfo);
$userinfo = null;
echo "User $username successfully imported!\n";
} catch (UserAlreadyExistsException $e) {
echo "User $username already exists...skipping.\n";
} catch (Exception $e) {
echo "Adding user $username failed - " . $e->GetMessage() . "\n";
echo "Bailing on user import...\n";
return 1;
}
}
return 0;
// vi: syntax=php ts=4
?>


The last one is just execute it
./user.php

Hope it helps for you all. And I also hope that the next version of Clarkconnect add function to add many users automatically just by import the file with webconfig.
^_^
 

different paths

college campus lawn

wires in front of sky

aerial perspective

clouds

clouds over the highway

The Poultney Inn

apartment for rent