I’ve written a script to automatically send email notifications to users who have access to a specific file or folder. However, I’m encountering issues retrieving the user details. Is it possible to achieve this through the backend or API?
What user details exactly? What issues exactly?
There are several occ commands to retrieve user information:
user@box:~# occ user:info --help
Description:
show user info
Usage:
user:info [options] [--] <user>
Arguments:
user user to show
Options:
--output[=OUTPUT] Output format (plain, json or json_pretty, default is plain) [default: "plain"]
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
--no-warnings Skip global warnings, show command output only
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
that one gives you various user informations about one specific user.
and
user@box:~# occ user:list --help
Description:
list configured users
Usage:
user:list [options]
Options:
-l, --limit[=LIMIT] Number of users to retrieve [default: "500"]
-o, --offset[=OFFSET] Offset for retrieving users [default: "0"]
--output[=OUTPUT] Output format (plain, json or json_pretty, default is plain) [default: "plain"]
-i, --info Show detailed info
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
--no-warnings Skip global warnings, show command output only
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
that gives you the information of ALL users.
Here an example to get one big json object with all the information of all users:
user@box:~# occ user:list -i --output=json
… the json object can then be parsed with jq or other json tools and is an ideal source for further use in a script.
Much and good luck,
ernolf