Skip to main content

"samba-tool" to Manage a Linux based Active Directory

A linux based Active Directory server can be managed from a Windows client using the Remote System Administration Tool very easily, and it is the convenient way for system administrators with only Microsoft Windows background. But for administrators who love to use the command line, "samba-tool" is a great command line tool to manage Active Directory configured on a Linux Box. Throughout this post and on my future posts I will be showing hands-on examples about using the "samba-tool" command.


User Management using samba-tool

Create a new user using samba-tool

Syntax: samba-tool user create <username> [<password>] [options]

samba-tool user create user1 password --given-name=firstname --surname=surname

The above command will create a new user with the name as user1 and password will be password, you can type your desired password. The options --given-name and --surname are to assign user first name and surname.


To make the user change password at first login add the option --must-change-at-next-login when creating the user


By default samba-tool creates the new user under the Users Organisational Unit, to create the user under a different OU use the option --userou='ou=OUNAME'



Set or reset password of a user

Syntax: samba-tool user setpassword (<username>|--filter <filter>) [options]

samba-tool user setpassword user1
or
samba-tool user setpassword --filter=samaccountname=user1

Both the above commands can be used to set or change password of a user


To force the user change password at next logon add option --must-change-at-next-login

samba-tool user setpassword user1 --must-change-at-next-login
or
samba-tool user setpassword --filter=samaccountname=user1 --must-change-at-next-login


To get detailed help and all the available options to create and manage users run this command
samba-tool user -h

Group Management using samba-tool

Create a new group

Syntax: samba-tool group add groupname [options]

samba-tool group add sales


The command above creates a new group named sales, because there is no options applied the group is created under the default organisational unit Users.

Change the group's OU and other parameters such group type and scope

samba-tool group add sales --groupou='ou=restrict' --group-type=Security --group-scope=Global


The above command creates a group sales under OU "restrict" with group type as security and group scope as global.

Add members to a group

Syntax: samba-tool group addmembers <groupname> <listofmembers> [options]

samba-tool group addmembers sales user1,user2,user3


Remove members from a group

Syntax: samba-tool group removemembers <groupname> <listofmembers> [options]

samba-tool group removemembers sales user2,user3


The above command removes the user2 and user3 from the group sales

List members of a group

Syntax: samba-tool group listmembers <groupname> [options]

samba-tool group listmembers sales


To get detailed help and all the available options to create and manage groups run this command:
samba-tool group -h


Comments

Popular posts from this blog

How to setup Active Directory in Linux using Samba4

Samba version 4 can work as a domain controller which is compatible with Microsoft Active Directory, companies can save licensing cost by switching to Samba4 for Active Directory. I will put below the complete steps. Software Requirements: 1. A latest linux based operating system, I will be using Centos 7 for this example, you can use any flavor of linux  2. We will be using Sernet Samba version 4.2, because the samba package provided in Centos 7 DVD uses MIT Kerberos which does not support Active Directory. Hardware Requirements: 1. A system with at least 1 GB RAM for better performance, at least 10 GB of disk space and a decent processor 2. You can use a desktop class or server class system depending on choice Download Links for required softwares: 1. Download Centos 7 DVD from the below link      CentOS 7 DVD 2. Download Sernet Samba & other required rpm packages      Sernet Samba 4.2 and other dependent packages for...

Recover Files

How to recover deleted files you though its lost forever You accidentally or mistakenly  deleted one of your Important file and now your are sure that its not available in backup then what you will do???. You've searched your hard drive. You've scoured the Recycle Bin. No sign of it? Don't panic. As long as you act quickly, you can usually bring that file back to life. And to accomplish that feat, you'll want to turn to a recovery program to help you undelete it. Three such applications: Recuva, EaseUS Data Recovery and Active Uneraser. With these programs, you can run a quick search for recently deleted files and conduct a more time-consuming but thorough scan to dig up older ones. You can scan external media, such as USB drives and SD cards, as well as your computer's internal disk. If you want to revive a deleted file, an old adage applies: the sooner the better. When you delete a file in Windows, that file first bounces to the Recycle Bin. You c...