Submitted By: Mario Fetka (geos_one) (mario dot fetka at gmail dot com) Date: 2010-01-29 Initial Package Version: 2.3.2 Origin: https://ml.mandriva.net/wws/arc/mds-devel/2010-01/msg00004.html Upstream Status: unknown Description: Add the bulk user import module diff -Naur mmc-agent-2.3.2.orig/conf/plugins/bulkimport.ini mmc-agent-2.3.2/conf/plugins/bulkimport.ini --- mmc-agent-2.3.2.orig/conf/plugins/bulkimport.ini 1970-01-01 00:00:00.000000000 +0000 +++ mmc-agent-2.3.2/conf/plugins/bulkimport.ini 2010-01-24 23:03:45.000000000 +0000 @@ -0,0 +1,2 @@ +[main] +disable = 0 diff -Naur mmc-agent-2.3.2.orig/contrib/bulkimport/README mmc-agent-2.3.2/contrib/bulkimport/README --- mmc-agent-2.3.2.orig/contrib/bulkimport/README 1970-01-01 00:00:00.000000000 +0000 +++ mmc-agent-2.3.2/contrib/bulkimport/README 2010-01-24 23:50:03.000000000 +0000 @@ -0,0 +1,120 @@ +Description: + +The bulk user management tool has been designed as a plugin for MDS. It reads a CSV file and then imports, deletes +and modifies user attributes for each user in the CSV file. It does this using a two step process and performs all the +changes while the user waits for the page to refresh. + +For each record, it calls the appropriate methods in the user base module of mmc (python back end). + +Installation: +The following changes are needed to mmc: + +1. Bug fix in PageGenerator, this has already been fixed up stream, but if not, apply the patch. +2. Add in a require to page generator and add menu item to sidebar of user plugin. + + +Apply patches from: bulkuserimport.patch +Apply patch, with + +cd /usr/share/mmc +patch -p1 < /tmp/bulkuserimport.patch + +Patched versions of the following files are included, but not needed if you apply the patch above: +./mmc-web/main.php +./mmc-web/modules/base/users/localSidebar.php +./mmc-web/includes/PageGenerator.php + + +The following files need to be installed: +cp -r ./mmc-web/modules/csvimport /usr/share/mmc/modules +cp ./etc/mmc/plugins/csvimport.ini /etc/mmc/plugins/ +cp -r ./mmc-python/plugins/csvimport /usr/lib64/python2.6/site-packages/mmc/plugins/ + +Restart mmc-agent after copying files. + +Usage: + +CSV Formatting: + +Delimiator: , +Wrapper: " +Escape characture: \ + +CSV Header requirements: + +Required attribute: "login" +Require for import: "password","firstname","surname" +Additional headers can be set and must match the attribute name in ldap, for example: +"login","password","firstname","surname","primarygroup","mail" + +Special attributes + +The following can be set to: yes or no. +createhomedir (yes by default) +files (default set to yes for delete operation, users home directory will be removed.) + +Defaults + +homdir (homedir/username by default) +primaryGroup (default primary group as per base.ini plugin config) + +Currently supported attributes are: + + * audio + * carLicense + * departmentNumber + * description + * files + * firstname + * gecos + * localityName + * login + * loginShell + * mail + * manager + * mobile + * organizationName + * pager + * password + * physicalDeliveryOfficeName + * postalAddress + * postalCode + * preferredLanguage + * primarygroup + * roomNumber + * surname + * telephoneNumber + * title + +Examples CSV file contents. Create some users: + +"firstname","surname","mail","login","password","telephoneNumber","localityName" +"User1","Last1","user1@example.com","user1","test1",,"Auckland" +"User2","Last2","user2@example.com","user2","test2",,"Auckland" +"User3","Last3","user3@example.com","user3","test3",,"Auckland" + +Modify the mail and loginShell attributes: + +"mail","login","loginShell" +"user1@oss.co.nz","user1","/bin/bash" +"user2@oss.co.nz","user2","/bin/zsh" +"user3@oss.co.nz","user3","/bin/zsh" + +Delete some users: + +"login" +"user1" +"user2" + +Generating user login names, email addresses, etc. + +This tool does not generate data for you. To generate data from a list of names, use functions in OpenOffice Calc, for example, to generate the +email address, use the function: + +=CONCATENATE(a1,"@example.com") + +and for user names: + +=LOWER(CONCATENATE(LEFT(B1),MID(C1,1,5))) +where B1 is first name, C1 is Last name. + diff -Naur mmc-agent-2.3.2.orig/mmc/plugins/bulkimport/__init__.py mmc-agent-2.3.2/mmc/plugins/bulkimport/__init__.py --- mmc-agent-2.3.2.orig/mmc/plugins/bulkimport/__init__.py 1970-01-01 00:00:00.000000000 +0000 +++ mmc-agent-2.3.2/mmc/plugins/bulkimport/__init__.py 2010-01-29 15:57:48.381422910 +0000 @@ -0,0 +1,47 @@ +# -*- coding: utf-8; -*- +# +# (c) 2009 Open Systems Specilists - Glen Ogilvie +# +# $Id: __init__.py 743 2008-12-15 14:20:35Z cdelfosse $ +# +# This file is part of Mandriva Management Console (MMC). +# +# MMC 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. +# +# MMC 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 MMC; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import socket +import ldap +import logging +import os +import os.path +import grp + +from mmc.plugins.base import ldapUserGroupControl +from mmc.support.config import * +from mmc.support import mmctools +import mmc + +INI = "/etc/mmc/plugins/bulkimport.ini" + +VERSION = "0.0.1" +APIVERSION = "1:0:0" +REVISION = int("$Rev: 1 $".split(':')[1].strip(' $')) + +def getVersion(): return VERSION +def getApiVersion(): return APIVERSION +def getRevision(): return REVISION + + +def activate(): + return True diff -Naur mmc-agent-2.3.2.orig/setup.py mmc-agent-2.3.2/setup.py --- mmc-agent-2.3.2.orig/setup.py 2010-01-29 15:56:43.394175082 +0000 +++ mmc-agent-2.3.2/setup.py 2010-01-29 16:00:13.916426330 +0000 @@ -8,5 +8,5 @@ author_email = "cdelfosse@mandriva.com", maintainer = "Cedric Delfosse", maintainer_email = "cdelfosse@mandriva.com", - packages = ["mmc", "mmc.support", "mmc.plugins", "mmc.plugins.base", "mmc.plugins.samba", "mmc.plugins.proxy", "mmc.plugins.mail", "mmc.plugins.network", "mmc.plugins.kerberos", "mmc.plugins.printstats", "mmc.plugins.printing", "mmc.plugins.userquota"], + packages = ["mmc", "mmc.support", "mmc.plugins", "mmc.plugins.base", "mmc.plugins.samba", "mmc.plugins.proxy", "mmc.plugins.mail", "mmc.plugins.network", "mmc.plugins.kerberos", "mmc.plugins.printstats", "mmc.plugins.printing", "mmc.plugins.userquota", "mmc.plugins.bulkimport"], )