Appearance
2.9.4 — NTFS Permissions, SMB & Active Directory
The photo-upload service is being rolled out inside a large company. The marketing team's photos already live on a shared drive that everyone opens as \\files01\marketing. Two thousand employees sign in to their Windows laptops each morning with the same company account. And a rule says only the marketing team may change those photos, while everyone else may only look.
Three pieces of Windows make that work, and you will meet all three in almost every company: NTFS permissions decide who may do what with each file, SMB lets a laptop open files that live on another machine, and Active Directory keeps the single list of who everyone is. This page explains each one, in that order, building on the permissions and identity ideas of 2.6.1 and 2.8.4.
1. NTFS permissions: access control lists
2.6.1 showed Unix permissions: three groups of rwx bits, for the owner, one group and everyone else. That is simple, and it cannot express "the marketing team may change this, the design team may read it, and one contractor may read only this one folder". Windows's NTFS file system (2.6.3) uses something richer: an access control list, or ACL, on every file and folder.
An ACL is a list of entries. Each entry, called an access control entry, says three things: who it is about, a user or a group; whether it allows or denies; and which rights. Here the upload service reads the ACL of a photo and turns it into objects.
ts
// photo-acl.ts — read a photo's access control list on Windows and turn it into objects
import { execFileSync } from "node:child_process";
import { writeFileSync } from "node:fs";
const RIGHTS: Record<string, string> = { F: "full control", M: "modify", RX: "read and run", R: "read", W: "write" };
writeFileSync("beach.jpg", "photo bytes");
const out = execFileSync("icacls", ["beach.jpg"], { encoding: "utf8" }); // (1)
const entries = out.split(/\r?\n/)
.map((line) => line.replace(/^beach\.jpg\s*/, "").trim())
.filter((line) => line.includes(":(")) // (2)
.map((line) => {
const [who, flags] = [line.slice(0, line.indexOf(":(")), line.slice(line.indexOf(":(") + 1)];
const codes = [...flags.matchAll(/\(([^)]+)\)/g)].map((m) => m[1]); // (3) e.g. ["I", "F"]
return {
who,
inherited: codes.includes("I"), // (4)
rights: codes.filter((c) => c !== "I").map((c) => RIGHTS[c] ?? c),
};
});
console.log(entries);
// Printed on a Windows laptop (the laptop and user names are replaced here):
// [
// { who: 'NT AUTHORITY\\SYSTEM', inherited: true, rights: [ 'full control' ] },
// { who: 'BUILTIN\\Administrators', inherited: true, rights: [ 'full control' ] },
// { who: 'MYLAPTOP\\dev', inherited: true, rights: [ 'full control' ] }
// ](1)icaclsis Windows's command for showing and changing ACLs. Its raw output looks likeNT AUTHORITY\SYSTEM:(I)(F), one entry per line.(2)Each entry line contains:(, the start of its codes.(3)The codes in brackets are the rights.Fis full control,Mmodify,RXread and run,Rread andWwrite.(4)Imeans the entry is inherited: it was not set on this file at all, but copied down from the folder above.
Three ideas in that output matter.
Inheritance. By default, a folder's entries flow down to everything inside it. That is why every entry above was marked I. Set "Marketing: modify" once on the marketing folder, and every photo inside, now and in future, gets it. Unix permission bits have no inheritance; each file has its own.
Figure 1 shows it on the marketing folder.
(I), including a photo that will only be added next year.Look at the third file. Nobody will ever set permissions on it, yet it will be protected correctly the moment it is created, because it inherits from its folder. That is why administrators set permissions on folders and almost never on individual files.
Deny wins. An entry can deny as well as allow. When Windows checks an access, it reads the entries in order, and an explicit deny placed before the allows wins. So "Contractors: deny write" on a folder overrides an "Everyone: modify" that would otherwise let them in. Deny entries are powerful and confusing, and most administrators use them sparingly.
Groups, not people. Good ACLs almost never name individual users. They name groups, such as Marketing or Design, and people are added to or removed from groups. When someone changes team, one group change updates their access to every file in the company. Those groups usually come from Active Directory, in section 3.
How Windows identifies users: SIDs and access tokens
Linux identifies a user by a number, the UID (2.8.4). Windows uses a longer, globally unique identifier called a security identifier, or SID, which looks like S-1-5-21-…-1104. Names are only labels for SIDs, which is why renaming a user does not break their permissions.
When you sign in, Windows builds an access token: a record holding your SID, the SIDs of every group you belong to, and the special privileges you have. Every process you start carries a copy of that token, inherited the same way as the environment in 2.9.3. When a process opens a file, the kernel's security reference monitor (2.9.1) compares the token's SIDs with the file's ACL. That is the Windows version of Linux checking a process's UID and GIDs against rwx bits.
The same idea explains the familiar "Do you want to allow this app to make changes?" prompt, called User Account Control. An administrator who signs in actually gets two tokens: a full one, and a reduced one with the administrator powers removed. Programs normally run with the reduced token. Only when a program needs administrator rights does Windows ask, and then start it with the full token. It is Windows's version of working as an ordinary user and using sudo for one command (2.8.4).
2. SMB: opening files on another machine
The marketing photos do not live on anyone's laptop. They live on a file server called files01. When a laptop opens \\files01\marketing\beach.jpg, it uses a network protocol called SMB, short for Server Message Block.
\\files01\marketing\beach.jpgis a UNC path: two backslashes, a server name, a share name, then an ordinary path inside the share. A share is a folder the server has chosen to offer over the network.- When a program on the laptop calls
openorreadon that path, Windows turns each call into an SMB request, sends it over the network tofiles01on port 445, and returns the answer as if the file were local. This is the network file system idea from the VFS of 2.6.3: ordinary file calls, carried to another machine. - "Mapping a network drive" just gives that path a drive letter, so
M:\beach.jpgmeans\\files01\marketing\beach.jpg.
Linux machines can speak SMB too, both as clients and as servers, through an open-source program called Samba. That is how a Linux server can offer shares to Windows laptops.
Two layers of permission, and an old version to avoid
A file reached over SMB is checked twice. First against the share's permissions, which control who may connect to the share at all and with what maximum rights. Then against the file's own NTFS ACL. The user gets the more restrictive of the two. A common administrator habit is to give broad share permissions and do the real control with NTFS ACLs, so there is one place to look.
SMB has had several versions. The first, SMB 1, from the 1980s, has serious security weaknesses. In 2017 the WannaCry ransomware spread across hundreds of thousands of computers in a few days through a flaw in SMB 1, encrypting files at hospitals, factories and offices around the world. Modern Windows disables SMB 1. SMB 3, from 2012, adds encryption of the data on the network and much better performance, and is what you should expect to see. Port 445 should never be reachable from the open internet.
3. Active Directory: one list of who everyone is
Two thousand laptops, dozens of file servers, printers, and applications such as the photo-upload service. If each machine kept its own list of users and passwords, a new employee would need an account on every one, and someone leaving would have to be removed from every one. Companies need one central list.
Active Directory, or AD, is Microsoft's central identity service for a company's network. It is a database, held on special servers called domain controllers, kept as several copies so the company never depends on one machine. It stores:
- every user, with their password and details;
- every group, such as
Marketing, and who is in it; - every computer that has joined the company's domain, the set of machines AD manages;
- and policies: rules applied to users and computers.
When a laptop has joined the domain, signing in to it checks your password against Active Directory, not against the laptop. The same company account then works on every company machine. And when you open \\files01\marketing, you are not asked for a password again: the file server checks your identity with Active Directory behind the scenes. That is single sign-on.
Under the hood, Active Directory speaks two standard protocols:
- LDAP, the Lightweight Directory Access Protocol, is how programs search and read the directory: "which groups is Asha in?", "list everyone in Marketing".
- Kerberos, named after the three-headed guard dog of Greek myth, is how sign-in is proved. After you sign in, the domain controller gives your laptop a ticket, an encrypted proof of who you are that lasts for some hours. When you open a file share, your laptop presents a ticket for that server instead of your password. The password itself never travels to the file server.
8.4.8 explains LDAP and Kerberos properly, step by step.
Group Policy
Active Directory can also push settings to every machine, through Group Policy. An administrator writes a policy once and attaches it to a group of users or computers. A policy might say "screens lock after 10 minutes", "install this certificate", "map drive M: to the marketing share", or "this registry value must be 1" (2.9.3). Every matching machine applies it when it starts and at regular intervals. It is how one IT team manages thousands of laptops consistently.
Active Directory and the cloud
Microsoft's cloud identity service, Entra ID, which used to be called Azure Active Directory, shares the name's history but is a different system built for web sign-in rather than for office networks. Many companies run both, synchronised, so the same account works on office laptops and on cloud applications. 8.4.9 covers it.
4. How the three fit together
Put the opening story back together. Figure 2 shows the whole picture, and the numbered steps below walk through it.
files01 for the photo over SMB, showing the ticket instead of a password. ③ The server checks the share permissions, then the NTFS ACL, and allows the change.- Asha signs in to her domain-joined laptop. Active Directory checks her password and her laptop gets a Kerberos ticket. Her access token lists her SID and her groups, including
Marketing. - She opens
\\files01\marketing\beach.jpg. Her laptop sends the request over SMB, presenting a Kerberos ticket instead of a password. - The file server checks the share's permissions, then the photo's NTFS ACL, which says
Marketing: modify, inherited from the folder. Her token contains theMarketinggroup, so she may change it. - Ben, from the design team, opens the same photo. His token has
Design, which the ACL allows only to read. He can view it, but saving fails with "access denied".
If the photo-upload service is to store its photos on that share, it needs its own identity in Active Directory, called a service account, added to the right group, exactly as a Linux service gets its own user in 2.8.4.
What the interviewer will push on
"What are NTFS, SMB and Active Directory, and how do they relate?" They are checking whether you can put the three in one picture. NTFS stores files and their ACLs on a disk; SMB lets machines open files on other machines over the network; Active Directory holds the users, groups and policies that the ACLs and sign-ins refer to. The tell is walking through one file access end to end. ⚑What is SMB protocol and Windows NTFS? [EQ-42]
"How do Windows ACLs differ from Unix permission bits?" An ACL can list any number of users and groups, each allowed or denied specific rights, and entries are inherited down folder trees; Unix bits cover only owner, one group and everyone else. Mention that explicit deny wins.
"What is a SID and an access token?" A SID is a unique identifier for a user or group; an access token is the record of a signed-in user's SIDs, group SIDs and privileges that every process they start carries, and which the kernel checks against ACLs. User Account Control works by giving administrators a reduced token by default.
"Why is SMB 1 dangerous?" It has serious, exploitable flaws; WannaCry spread through one in 2017. Use SMB 3, and never expose port 445 to the internet.
"How does single sign-on to a file share work in an Active Directory domain?" The domain controller issues a Kerberos ticket at sign-in; the laptop presents a ticket for the file server instead of a password; the server trusts the ticket because it trusts the domain controller. ⚑What is Microsoft Active Directory in the context of SMB/NTFS? [EQ-42b]
Something to volunteer that nobody asks for: effective access to a share is the more restrictive of the share permissions and the NTFS permissions. When someone has "full control" on the folder but still cannot write over the network, the share permissions are almost always the reason.
Recall
- NTFS protects each file with an access control list: entries naming a user or group, allow or deny, and rights such as full control, modify, read. Entries are inherited down folders, explicit deny wins, and good ACLs name groups, not people.
icaclsshows them. - Windows identifies users by security identifiers (SIDs). Signing in builds an access token of SIDs and privileges, carried by every process and checked against ACLs. User Account Control gives administrators a reduced token by default.
- SMB carries ordinary file calls to a server, addressed as
\\server\share\pathon port 445; Samba lets Linux speak it. Share permissions and NTFS permissions both apply, and the stricter wins. SMB 1 is unsafe (WannaCry, 2017); use SMB 3. - Active Directory is the central directory of users, groups, computers and policies, held on replicated domain controllers. Domain-joined machines give single sign-on, using LDAP to read the directory and Kerberos tickets to prove identity.
- Group Policy pushes settings to many machines; Entra ID is Microsoft's separate cloud identity service.
Self-test: What does (I)(F) mean in icacls output? Why do good ACLs name groups rather than people? What two checks happen when a file on a share is opened, and which wins? How does the file server know who Asha is without asking for her password? Why should a service that stores files on a share have its own account?
Quiz Bank
FoundationalWhat are NTFS, SMB and Active Directory, and how do they relate?
NTFS is Windows's file system; it stores files and protects each with an access control list. SMB is the network protocol for file and printer sharing: it turns file operations on a path such as \\server\share\file into requests to a remote server, and Linux can speak it through Samba. Active Directory is the central directory service that stores a company's users, groups, computers and policies on domain controllers, and authenticates users with Kerberos. Together, NTFS holds and protects the files, SMB shares them over the network, and Active Directory supplies the identities and groups that both check.
FoundationalHow do NTFS access control lists differ from Unix permission bits?
Unix permissions are nine bits: read, write and execute for the owner, one group and everyone else. An NTFS access control list is a list of any number of entries, each naming a user or group, saying allow or deny, and listing specific rights such as read, write, modify or full control. Entries are normally inherited from parent folders to everything below them, and an explicit deny takes precedence. ACLs can express "this team may modify, that team may read, this person may not write" on one folder, which Unix bits cannot.
AppliedA user has full control on a folder's NTFS permissions but cannot save files to it over the network share. Why?
When a file is reached over SMB, two sets of permissions apply: the share's own permissions, which limit what anyone connecting through that share may do, and the file's NTFS ACL. The effective access is the more restrictive of the two. If the share grants only read access, the user can read but not write, whatever the NTFS ACL says. Check the share permissions; a common practice is to make them broad and do the detailed control with NTFS ACLs, so there is one place to manage.
InterviewWhat is an access token in Windows, and how is it used?
When a user signs in, Windows creates an access token containing the user's security identifier, the identifiers of all the groups they belong to, and their privileges. Every process the user starts receives a copy. Whenever a process opens a file or another protected object, the kernel compares the token's identifiers with the object's access control list to decide what is allowed. Administrators normally receive two tokens, a full one and a reduced one; programs run with the reduced one until User Account Control asks for permission to use the full one, much like using sudo on Linux.
InterviewHow does single sign-on to file shares work in an Active Directory domain?
When a user signs in to a domain-joined computer, it verifies the password with a domain controller using Kerberos and receives a ticket, an encrypted, time-limited proof of identity. When the user then opens a file share, the computer asks the domain controller for a ticket for that file server and presents it over SMB; the server can check the ticket because it trusts the domain controller, so no password is sent or asked for. The user's group memberships, read from the directory, then decide what the NTFS permissions allow.
StaffA company still has SMB 1 enabled on old file servers for a legacy scanner. Lay out the risk and a migration plan.
SMB 1 has serious, well-known vulnerabilities; the WannaCry outbreak of 2017 spread automatically between machines through one of them, encrypting files across entire networks. Any machine that still accepts SMB 1 is a path for that kind of worm, and one infected laptop inside the network is enough.
A migration plan:
- List which devices actually need SMB 1. It is usually a few scanners or old appliances.
- Give those devices an isolated network segment, or one small server that accepts SMB 1 only from them and forwards the files onward.
- Disable SMB 1 on every other server and laptop.
- Upgrade or replace the old devices. Many support newer SMB versions after a firmware update, or can deliver files another way, such as email or a cloud upload.
- Block port 445 at the network edge entirely.
Track the remaining exceptions with an end date.
Scenario Drill
DrillThe photo-upload service, running as a Windows service under the built-in system account, must save photos to \\files01\marketing, but every write fails with access denied, although an administrator can write there. Using this page, explain and fix it.
The service runs with the access token of the account it was configured to run as. A local built-in account has no identity of its own that the file server recognises in the Marketing group, so the share and NTFS permissions do not allow it to write. The administrator succeeds because their token includes groups that are allowed.
The fix is to give the service its own identity in Active Directory: a dedicated service account, or a managed service account that Active Directory rotates the password for automatically. Run the Windows service as that account, add it to a group that the share and the folder's ACL allow to modify, and grant nothing more. Do not fix it by giving "Everyone" write access, or by running the service as an administrator: both would let any compromise of the service write anywhere. This is the least-privilege rule of 2.8.4, applied to a Windows network.
Next: the last page of Part 2 answers two everyday curiosities about the desktops you use: how Windows and macOS draw their windows and buttons, if not with CSS like a web page, and how a plain .txt file differs from a document that can hold bold text. Page 2.9.5 explains both.