phpgroupware-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Phpgroupware-users] Bulk loading user accounts


From: Benoit Hamet
Subject: Re: [Phpgroupware-users] Bulk loading user accounts
Date: Tue, 18 May 2004 18:28:30 +0200
User-agent: Mozilla Thunderbird 0.5 (X11/20040306)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all

I do this kind of stuff from a internal app table (of phpgw)
to ldap account.

Somtehing like that :
call in a foreach loop should work.

$content is an array containing users info from my app. ($content['contact'] == mail address in my case)

function create_user($content)
        {
if ( $GLOBALS['phpgw']->accounts->name2id(strtolower($content['contact'])) )
            {
                return False;
            }
            $account_info['account_lid'] = strtolower($content['contact']);
            $account_info['account_type'] = 'u';
$account_info['account_passwd'] = md5(mt_rand().strtolower($content['contact'])); $account_info['account_firstname'] = ucfirst(strtolower($content['prenom'])); $account_info['account_lastname'] = ucfirst(strtolower($content['nom']));
            $account_info['account_status'] = 'A';
            $account_info['account_expires'] = '-1';
            $account_info['mail'] = strtolower($content['contact']);
            $account_info['person_id'] = 'NULL';
            $GLOBALS['phpgw']->accounts->create($account_info);
$accountid = $GLOBALS['phpgw']->accounts->name2id(strtolower($content['contact'])); $default_group_lid = $GLOBALS['phpgw_info']['server']['default_group_lid']; $default_group_id = $GLOBALS['phpgw']->accounts->name2id($default_group_lid); $defaultgroupid = $default_group_id ? $default_group_id : $GLOBALS['phpgw']->accounts->name2id('Default');
            if ($accountid)
            {
                if ($defaultgroupid)
                {
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('phpgw_group', " . $defaultgroupid . ', ' . $accountid . ', 1)',__LINE__,__FILE__); $this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('preferences', 'changepassword', " . $accountid . ', 1)',__LINE__,__FILE__);
                }
                else
                {
// If they don't have a default group, they need some sort of permissions. // This generally doesn't / shouldn't happen, but will (jengo) $this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('preferences', 'changepassword', " . $accountid . ', 1)',__LINE__,__FILE__);
                    $apps = Array(
                        'addressbook',
                        'calendar',
                        'email',
                        'notes',
                        'todo',
                        'phpwebhosting',
                        'manual'
                    );
                    @reset($apps);
                    while(list($key,$app) = each($apps))
                    {
$this->db->query("INSERT INTO phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) VALUES ('" . $app . "', 'run', " . $accountid . ', 1)',__LINE__,__FILE__);
                    }
                }
            }
            else
            {
                return False;
            }
            return True;
        }



Hope this help.

Regards,
Caeies.

I haven't done this so don't know if it is practical:
1. dump from the mysql ldap backend
2. edit the resulting ascii file to change them into suitable insert
statements for phpgw_accounts
3. insert them

I'm not sure if you would also have to add entries into phpgw_prefs and
phpgw_acl or if they would be created easier some other way

The prefs one may be autocreated when the user logs in

The acl one you could maybe create by going into the admin screens and add the
accounts to a group with suitable permissions



Simon Ward (address@hidden) wrote:

Has anyone devised a way of bulk loading user accounts ?
I'm using an LDAP server, but I can't simply create a big LDIF file as
group membership and email account configuration seems to be stored in
the MySQL back end.

If anyone has any thoughts or suggestions let me know, as I don't really
fancy building 200+ accounts by hand :)

Thanks,
Simon


_______________________________________________
Phpgroupware-users mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/phpgroupware-users






_______________________________________________
Phpgroupware-users mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/phpgroupware-users

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAqjmud/RrA5d/NgMRAs2sAJ9RXesU5CigYF0is8vLfhQBVeSu0QCghJjH
F2K/xWqWIE2hveavnMX2Edg=
=k/L7
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]