List owncloud users

9.1.x

#1

Hello

I'm looking to use the users list in a bash script on my owncloud server. I looked for a occ command (without LDAP), but I did not find, does it exist?
If not how to operate? Without making a mysql query ... Which would oblige to request id and pw from the database to the user.
Thank you


#2

Hi,

why don't you log in to you db as root and do

select uid from oc_users

you only need the root password.


#3

Hi Patlol,

in 9.1.x there is no such command. However in the upcoming 10.0.3 release this will be possible by using the below commands:

  • user:list --> list users
  • user:list-groups --> list groups for a user

Please refer to the following link for more details: https://doc.owncloud.org/server/10.0/admin_manual/configuration/server/occ_command.html#user-commands-label


#4

Thanks you dimitry and pako81

I dont want use query, because the script doesn't know the mysql root password
I think I will switch to v10...


#5

you know, you can simply cat on the password file and then you will have your password?

something like this:

mysql -u owncloud -p$(cat /etc/owncloud.secret) owncloud -e "Your Command"

But Updating to 10 is always better :slight_smile:


#6

yes dimitry it's a good idea, but /etc/owncloud.secret don't exist on my debian 8 or ubuntu 16 distrib.

But i have /etc/mysql/debian.cnf it's contain

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = xxxxxxxxxxxxxxxxx
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = xxxxxxxxxxxxxxxxx
socket   = /var/run/mysqld/mysqld.sock
basedir  = /usr

and in my script with

userBdD=$(cat "/etc/mysql/debian.cnf" | grep -m 1 user | awk -F"= " '{ print $2 }')
pwBdD=$(cat "/etc/mysql/debian.cnf" | grep -m 1 password | awk -F"= " '{ print $2 }')
repQuery=$(echo "SELECT * FROM owncloud.oc_group_user;" | mysql -BN -u $userBdD -p$pwBdD)

I've got all I need


#7

glad to hear that :slight_smile:


#8

Hello this comand
user:list
user:list-groups

is removed now !!!???

Fortunately there is the above solution! It is valid for debian 8, 9 and ubuntu 16


#9

They will be added back to the docs soon. However those commands are already available on 10.0.3


#10

Ok i am testing today!!!


#11

with
sudo -u www-data /var/www/owncloud/occ user:list

  [Symfony\Component\Console\Exception\CommandNotFoundException]  
  Command "user:list" is not defined.                             
  Did you mean one of these?                                      
      app:list                                                    
      files_external:list                                         
      market:list                                                 
      config:list                                                 
      encryption:list-modules                                     
      user:sync                                                   
      user:setting                                                
      user:resetpassword                                          
      user:disable                                                
      user:delete                                                 
      user:enable                                                 
      user:lastseen                                               
      user:report                                                 
      user:add

nothing else :cry:
i use owncloud-10.0.2 maybe in version 10.0.3 ...


#12

The commands are available starting with 10.0.3 only. So no 10.0.2..