Docs Version v0.2
Docs menu

People and groups

Directory sync: Google Workspace, Microsoft Entra ID and LDAP

Changed 7 min readv0.2

On this page

Introduction

Acme already keeps its people in a company directory, such as Google Workspace, Microsoft Entra ID or Active Directory. Entering them all again in Signari would be slow, and the two lists would soon disagree.

A "directory sync" reads people from that directory and makes Signari match it. It creates the people who joined, updates the people who changed, and deactivates the people who left. A mistake here can deactivate everybody at once, so a new source changes nothing until you have read what it would do.

You add a source with signari dir add, or through the Admin API. A source can be Google Workspace, Entra, or a Lightweight Directory Access Protocol (LDAP) directory.

Note

To read OpenLDAP, Active Directory or FreeIPA, see LDAP as a source.

Add a source and sync it

These commands add a Google Workspace source, an Entra source and an LDAP source, then preview a sync and apply it:

Shellsignari dir add -org <uuid> -kind google -slug workspace \  -file service-account.json -domain example.com -impersonate admin@example.comsignari dir add -org <uuid> -kind entra -slug tenant -file entra.json# LDAP, Active Directory and FreeIPA: see docs/ldap-source.mdsignari dir add -org <uuid> -kind ldap -slug corp -ldap-url ldaps://dc01:636 ...signari dir sync -slug workspace            # preview, writes nothingsignari dir sync -slug workspace -apply

In this example, -impersonate names the Google administrator the service account acts as. The ... on the LDAP line stands for the LDAP settings, which LDAP as a source lists.

The Admin API registers, tunes, maps and syncs sources the same way, under /admin/organizations/{orgID}/directories. It runs the same sync as the command. See the Admin API.

Guard against mass deactivation

A filter can match fewer people than intended. A paginated fetch can stop early, or an API can return an empty page during an outage. Each of those looks the same as "everybody left the company", and a sync that trusts it deactivates them all.

So the defaults are cautious:

dry_runtrue: a new source writes nothing until told twice
on_missingreport: names who would go, deactivates nobody
max_deactivate_percent20: above this the whole sync is refused

You turn each off yourself, after you have read a dry run. A "dry run" reports what a sync would do, and changes nothing.

Refused, not truncated

A plan that would deactivate more than the ceiling is refused entirely. It is not applied in part, and not trimmed to the first N. A number that large means the input is probably wrong, so none of it is applied.

This is the message a refused sync prints:

Textthis sync would deactivate 50 of 50 active users (100%), over the 20% ceiling.Nothing has been applied. A cliff like this is almost always a bad fetch -- afilter matching too little, a truncated page, an upstream outage -- rather thanthat many people leaving at once.

The ceiling is enforced in Apply as well as in the caller. Apply is the function that makes the changes, so a future caller cannot skip the check.

Reactivations are not counted against it, because the ceiling exists to stop mass removal.

Matching is on the remote id, never on email

Suppose Ada changes her surname, and her email address with it. Matching on email reads that as a departure plus an arrival: one account deactivated, one created, and the person locked out of everything they owned.

core.directory_links is keyed on the upstream's immutable ID. A remote record without one is skipped, rather than matched by address.

Each link also keeps the display name the directory last sent, and the next sync compares against it. So a second sync of an unchanged directory proposes nothing.

A new remote record whose address matches an existing local account adopts it, which links the record to that account instead of creating another. The exception is a person who may act as other people through impersonation. Such a person is never adopted, and a linked person who later came to administer is never re-addressed by the directory.

Each skip is recorded as directory.privileged_skipped, and the rest of the run carries on. Deactivation is never skipped, because a departed administrator must stop getting in.

Somebody a paged fetch returns twice is one person, and the later entry is the one kept. Two different entries with one address are two people claiming one account. A source links a person once, so the run stops, names the address and changes nothing. Fix it upstream and sync again.

A run is one transaction. Anything else writing addresses or usernames in that organisation waits for it to commit. Creating 100,000 people takes about eight seconds on a laptop, and a later run touches only what changed.

A failed page is an error

The Google and Entra adapters both treat a failure part-way through pagination as an error, never as a shorter list. The reconciler cannot tell "these are all the people" from "these are the ones read before something broke". So the fetch must not return a partial list.

  • Google paginates with nextPageToken. A service account also needs domain-wide delegation and an administrator to impersonate. That is checked up front, because Google's 403 does not say what is missing.
  • Entra paginates with an absolute @odata.nextLink carrying an opaque skip token, followed as given. Rebuilding the query from parts loses the token, and reads page one again in a loop.

Both cap pagination at 500 pages rather than looping without bound.

Google's scope is admin.directory.user.readonly. A sync only reads the directory, so it is not given write access to Workspace.

On a schedule

A source can sync itself, so that somebody who left stops signing in without a cron job:

Shellsignari dir set -slug corp -sync-interval 3600    # hourly; 300 to 604800 seconds, 0 stops it

signari serve looks every minute for what is due, and runs dir sync -apply with every rule that has. The first run is one interval after the setting is made, so setting it applies nothing at once.

A plan past the ceiling is refused. A scheduled run has no terminal, so the refusal goes on the source as its last error. dir list and the Admin API show it there. It also goes into the audit trail as directory.scheduled_sync.

A failed sync waits for its next turn, rather than being asked again every minute. A disabled source, one in dry run, and any in a suspended organisation are left alone. So a schedule is safe to set before a source is trusted.

When Signari runs on several nodes, one node takes each source. A sync that runs past thirty minutes loses its turn.

What a sync does in each case

A sync handles each of these cases as shown:

create, then re-sync unchangedsecond run proposes nothing
a user removed upstreamdeactivated, sessions ended, each application they reached sent a back-channel logout notice
a user still presentuntouched
empty directory, 50 users localrefused, nothing written
two leavers out of fiftyallowed
a renameone update, not a delete plus a create
suspended or archived upstreamdeactivated here
a page failing mid-fetcherror, and no partial list returned
mail empty in Entrafalls back to userPrincipalName

Groups

A sync reconciles group membership only when the source fetches groups, and only for groups an administrator mapped. These commands turn on fetching groups, and map a remote group to a group in Signari:

Shellsignari dir set -org <uuid> -slug corp -fetch-groupssignari dir group-map -org <uuid> -slug corp \  -remote-group 'cn=engineering,ou=groups,dc=example,dc=com' -group engineering

Each kind of source names a group its own way. An LDAP group is named by its distinguished name (DN), its full name in the directory:

SourceWhat a group is calledNestingNeeds
LDAPits DN, from memberOf or -group-attributeActive Directory: resolved for each mapped group with the in-chain matching rule; elsewhere, direct onlyread access to the attribute
Entraits object idtransitive (transitiveMemberOf)GroupMember.Read.All
Googleits addressdirect onlyadmin.directory.group.readonly delegated

The names are chosen so that a mapping cannot be claimed from upstream. A display name is not unique, and anybody able to create a group could give one the name of a mapped group. An ID, an address or a DN cannot be reused that way.

A source that does not fetch groups changes no membership. That is different from a source saying somebody is in no groups. Removals are bounded by the same ceiling as deactivations.

Fetching is off by default, because it needs more of the upstream than reading people does.

Compatibility

The LDAP source works with OpenLDAP, over Transport Layer Security (TLS) with a private certificate authority (CA). That includes a rename across organisational units and a server-side size limit. See LDAP as a source.

The Google and Entra adapters follow the documented response shapes. Pagination, error handling, credential exchange and the reconciler work against those shapes. Whether real Google and real Microsoft match them is not yet known. Run a dry run first, and read it.