[Samba] how edit users via script

Rowland Penny rpenny at samba.org
Thu Jun 22 09:18:40 UTC 2023



On 22/06/2023 10:05, Anton Shevtsov via samba wrote:
> [root at dc extend]# rpm -q samba
> samba-4.16.10-alt1.x86_64
> 
> [root at dc extend]# cat /etc/os-release
> NAME="ALT Server"
> VERSION="10.1"
> ID=altlinux
> VERSION_ID=10.1
> PRETTY_NAME="ALT Server 10.1 (Mendelevium)"
> ANSI_COLOR="1;33"
> CPE_NAME="cpe:/o:alt:server:10.1"
> BUILD_ID="ALT Server 10.0"
> HOME_URL="https://basealt.ru/"
> BUG_REPORT_URL="https://bugs.altlinux.org/"
> 
>> I ask this because it is working for myself.
>>
> ok, how i can add , for example, 'department' attribute for all simpleuser*
> 
> for i in $(samba-tool user list | grep '^simpleuser'); do
> 
> samba-tool user edit $i | sed/awk/anythinghere ?
> 
> done

I do not think that 'samba-tool user edit' was meant to be used in that 
way, it just opens up the users object in an editor and allows you to 
edit it manually e.g. you could add the attribute and value manually and 
then save and close the editor.

For what you are trying to do, I would use ldbmodify and an ldif

Rowland




More information about the samba mailing list