bpcurse / nextcloud-userexport

PHP script to export and filter lists (users, groups and groupfolders) using different Nextcloud APIs
The Unlicense
11 stars 3 forks source link
csv email export filter nextcloud nextcloud-ocs-apis usermanagement

Nextcloud userexport

PHP script to export users, groups and groupfolders using Nextcloud's OCS APIs user metadata, capabilities and groupfolders via cURL.

How it works

The script uses cURL to make calls to Nextcloud's OCS APIs and displays the results either through an HTML table or a CSV list that can be easily copied to calc/excel. You can download a CSV formatted file as well.

https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-api-overview.html#user-metadata https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-api-overview.html#capabilities-api https://github.com/nextcloud/groupfolders#api

Installation

Update

General usage

After the script has successfully downloaded user, group (and groupfolder) data you can access other options from the top navigation bar.

Security

Performance

API calls via cURL are slow. Querying several hundred user accounts can take some minutes. Be patient :)

CURL parallel requests have been implemented since v0.2.0 and provide a relevant speed boost, but that's about as fast as it gets. Approximately 10-15s/100users.

A progress indicator is on the wish list.

Menu items in top nav bar

Users

Groups

Groupfolders

(only visible if groupfolders app is active and at least one groupfolder is in use)

All tables can be sorted by clicking on the column headers (although not by size).

Email

Clicking 'create list' will open your email application with a 'mailto:' string containing all (filtered) email addresses.

Statistics

Logout

Parameters

You can use the following GET parameters with this script:

Nextcloud target instance and user credentials

Display type (display of the results page)

Message Mode (how to send mass email)

Select data to export

Examples:

https://mydomain.org/userexport.php/?url=https://cloud.example.com&user=myusername&pass=goodpassword&type=csv
https://userexport.mydomain.org/?url=https://cloud.example.com&user=myusername&msg_mode=to&select=id,displayname,enabled,used,lastLogin

If you do not supply one of the parameters you can fill in the corresponding fields afterwards in the form (e.g. password). Prefilled form fields can also be edited by user input.

Configuration

Several options can be set in config.php. The options are described in comments.

Localization

This software can be translated by adding a language file to the l10n directory. To translate, duplicate an existing {ISO lang code}.php file, preferably en.php, rename it to the new language code and start translating by editing the lines inside. An overview of ISO language codes can be found in the l10n directory, too.

At present, included languages are English (default) and German. Set the language option inside config.php to select a language.

Nextcloud integration

You can integrate it by using the external sites app.

Known Issues

Sorting tables by sizes (quota) is not possible, yet. (The sort function cannot handle human readable formats like 50 GB)

Development

Any hints to enhancements or security issues are highly welcome. If you would like to contribute, please open an issue or a pull request.

Minor version updates and bugfixes (x.x.1) are not always released separately. If you want to use the latest version please download/clone from master.

You can still use the simpler v0.4.1, if you prefer.

Additional Info

Inspired by comments to this github issue: https://github.com/nextcloud/server/issues/14715

Screenshots (still v1.0.0, TODO)

Login page nextcloud-userexport_v1 0 0_login_page

Data selection nextcloud-userexport_v1 0 0_users_page

Userlist nextcloud-userexport_v1 0 0_users_details_page