File upload


upload

Account selection (masscreate.php)

This is the initial page of the file upload. The user selects the account type for the new upload.


Attribute overview (masscreate.php)

After the account selection LAM will display an overview of the possible and required input columns.
The DN attributes (DN suffix and RDN) are static and are always displayed. The default suffix is read from config with getAccountSuffix() and the list of RDN possibilities is taken from modules.inc - getRDNAttributes().
The next attributes are read from modules.inc - getUploadColumns(). LAM will display all attributes of one module in a separate fieldset. The getUploadColumns() function also returns if an attribute is required and additional information like an example value.

After clicking the upload button the user will be forwarded to the account building page.


Account building (massBuildAccounts.php)

This part takes the submitted CSV file and generates the LDAP accounts.

The scripts separates the head row from the data rows in the CSV file. The head array is used to find the position of the input values. The data array contains one subarray for each account.

After the data has been extracted there are some basic checks done, e.g. checking required and unique columns. The modules provide the necessary information for this.

Then all data is given to the modules with buildUploadAccounts() in modules.inc. They return a list of accounts which can be uploaded with ldap-add() and generate possible error messages.

If the accounts are built the script will give the user the possibility to check the result with an LDIF-file or to do the upload.


LDIF export (massBuildAccounts.php)

LAM simply takes the built accounts and generates an LDIF-file from them. This is passed to the user's browser.
The LDIF-file will only contain the accounts itself. If modules do additional tasks after the upload (e.g. adding users to groups) this will not be covered.


Account creation (massDoUpload.php)

This script finally uploads the LDAP accounts with ldap_add().

The upload can last longer than the maximum execution time of PHP. Therefore the script will check regulary how much time is left and pause the upload. This is resumed with a meta refresh which loads the script again.

After all accounts were created in LDAP the modules may do additional tasks. LAM will call doUploadPostActions() and also provide a list of failed accounts which can be ignored. The function is called as long the returned status is "inProgress". The script uses again a meta refresh to handle the maximum execution time.
Typical post actions are setting quotas or adding an user to groups.

A progress bar is shown for the LDAP adding and the module actions to give the user a hint how long it will still take.