PHP script to export users, groups and groupfolders using Nextcloud's OCS APIs user metadata
, capabilities
and groupfolders
via cURL.
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
index.php
in a browser. You can point a subdomain like https://export.cloud.example.com
at it.config.php
if you have set non-default values.After the script has successfully downloaded user, group (and groupfolder) data you can access other options from the top navigation bar.
Do not use http://
unless you have a very good reason to do so.
The script will block outgoing plain HTTP connections and warn you unless you override this security measure with !http://...
Group admins (as long as they do not belong themselves to the admin
group) will not receive information on users that are members of admin
group, even if they are members of the group the group admin manages. This is a restriction of Nextcloud itself.
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.
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
You can use the following GET parameters with this script:
Nextcloud target instance and user credentials
url
URL incl. protocoluser
admin username to query the recordspass
user password - not recommendedDisplay type (display of the results page)
type
table
display html formatted table [default]csv
display comma separated valuesMessage Mode (how to send mass email)
msg_mode
bcc
recommended for privacy and legal reasons [default]to
cc
Select data to export
select
id
, displayname
, email
, lastLogin
[case sensitive!], backend
, enabled
, total
, used
, free
, groups
, subadmin
, language
, locale
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.
Several options can be set in config.php. The options are described in comments.
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.
You can integrate it by using the external sites app.
https://export.cloud.mydomain.com/?url=https://cloud.example.com&user={uid}
Sorting tables by sizes (quota) is not possible, yet. (The sort function cannot handle human readable formats like 50 GB
)
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.
Inspired by comments to this github issue: https://github.com/nextcloud/server/issues/14715
Login page
Data selection
Userlist