Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Active Directory Basics

The whole lesson is free and interactive. Read it here, or press Start lab to run it for real in a live lab, with no account needed.

Virtual machine lab7 min read4 commands

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

One machine says who everyone is

In a college with hundreds of staff and students, one system holds every account and decides who may sign in where. On a Windows network that system is Active Directory, and the machine that runs it is a domain controller. This lab is one, built with Samba. Read and change only your own copy, and a real directory only with written permission.

By the end of this lesson

Note

I can list the accounts and groups in my own directory and read one account plainly.

Key words

  • Directory: the store of a network's accounts, groups and machines.
  • Domain controller: the machine that runs the directory and checks sign-ins.
  • Account: a user, such as jadams, or a computer, such as WEB01$.
  • Group: a set of accounts, such as Domain Admins.
  • samba-tool: the command that reads and changes this directory.

Starter: what you already know

Note

Answer in your head. 1. What is a user account? 2. Why do some people on a network have more power than others? 3. Where should the list of everyone's accounts be kept, on each laptop or in one place? You need the third answer in a moment.

Before you start

Note

Press Start the lab on the bar at the top of this lesson. This lab is a whole Ubuntu machine of your own, so it takes a little longer to come up than a container, and the first start sets up the directory. Each Run button types its command into the machine's terminal, one after another. If one says the machine is still starting, wait a few seconds and press it again. To watch them, or to type your own, press Open terminal on the bar.

List the accounts

The directory already has a few accounts. samba-tool user list prints every one. You run it with sudo, because reading the directory needs administrator rights on this machine. You should see six names.

Command
sudo samba-tool user list | sort

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Check

Tip

Which of the six is a service account, not a person? Answer: svc-sql. It is an account a program signs in as, not a member of staff. krbtgt is a built-in account the directory uses for itself.

Read one account plainly

An account has attributes: its short name, its email-style name, its first name and surname. ldbsearch reads them from the directory's database. This reads Jade Adams, a member of staff, and asks for four of her attributes.

Command
sudo ldbsearch -H /var/lib/samba/private/sam.ldb '(sAMAccountName=jadams)' sAMAccountName givenName sn userPrincipalName

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Check

Tip

What is Jade's sign-in name? Answer: jadams, and her Kerberos name is [email protected]. The directory is called AD.COLLEGE.LAB.

List the groups

A group gathers accounts so they can be given rights together. samba-tool group list prints them. The one to notice is Domain Admins: anyone in it controls the whole directory.

Command
sudo samba-tool group list | sort

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

A common mistake

Warning

Many people think the danger in a directory is a weak user password. It matters, but the bigger danger is an account in a powerful group that should not be, or a service account nobody watches. This module is about finding those.

List the service accounts

A service account is one a program signs in as. The module's lesson 4 is about why a weak service account is dangerous. This reads every user account with a service name set. Two come back: svc-sql, and krbtgt, the built-in account Kerberos uses.

Command
sudo ldbsearch -H /var/lib/samba/private/sam.ldb '(&(servicePrincipalName=*)(objectCategory=person))' sAMAccountName servicePrincipalName

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Exit check

Tip

Answer without looking back. 1. What does a domain controller do? 2. What is Domain Admins? 3. What is a service account? 4. Which command lists every account? Answers: it runs the directory and checks sign-ins; the group that controls the whole directory; an account a program signs in as; samba-tool user list. Now open README.md in your home folder with cat ~/README.md: it lists the accounts and the rule.

For teachers

Tip

This lesson is a small example of a lesson worked in a lab: the steps and the Run buttons are the lesson, and the lab is each student's own copy. This lesson is worked in a VM lab: each student has an Ubuntu machine running a Samba Active Directory domain controller, and a Run types into its terminal and shows what it printed. Key learning points: 1. A directory holds a network's accounts and groups in one place. 2. A domain controller runs it and checks sign-ins. 3. Accounts have attributes you can read. 4. Powerful groups and unwatched service accounts are the real risk. Common mistake: thinking a weak user password is the whole story. Equipment: the lab and a browser, and a free or college account, since the setup installs Samba from Ubuntu's archive. The module 131 lessons audit and then fix four planted weaknesses on this directory; this lesson only looks around. Every password in the lab is a planted practice fixture, said so in the README. Copy it into your own module and change it, or build one from scratch with the Lab menu in the lesson builder.

Teaching a class? Set these lessons for your students with marking and a lab for every student.