Versione italiana disponibile qui → [IT]
Reader’s note: the opening scene is fictional, the historical context is real. The parallel between grafting, Shibboleth and Entra ID is the author’s own interpretation. The technical sections operate in a grey area, not officially supported, and distinguish what is documented from field experience. This English version was translated from the original Italian with the assistance of artificial intelligence and subsequently reviewed by the author.
Friday 25 April 2003, we are in Brisighella, in the hills near Faenza, deep in Romagna.
All over Italy people are celebrating Liberation Day, which came 58 years earlier, but the olive grove doesn’t know it. Those who work this land are well aware: farming follows the seasons, not the calendar.
Dino is thirty and has the ease of someone who learned by watching these gestures many times. The unusual cold of early April is behind him, the tree is starting to wake up and the bark lifts cleanly under the blade. In these conditions there is no time to lose.
The olive grove belongs to his father, Iames, with an I. The family story is that it’s a tribute to the soldiers who liberated this land; after all, in Romagna names you won’t find in any saints’ calendar have always been around.
The trunk in front of him has many years behind it, spent in a land that is generous, but only with those who know it well, and by now it is deeply rooted. The time has come, though, to renew the harvest.
Dino makes a vertical cut a few centimetres long in the smooth bark of the old trunk, which from today will serve as the rootstock. He prepares the scion, a twig with three or four buds, its base cut on a long slant, and slips it in where the two skins meet, because it is there, in the cambium, the thin living layer just beneath the bark, that the two plants will have to recognise each other. Then tape and grafting wax. Only time will tell whether the work has been done well.
On the dry-stone wall there’s a small portable radio that keeps Dino company on his solitary days. He likes dance music, and right then the radio is playing one of his favourite tracks: “Make Luv” by Room 5. The rhythm gets to him and his mind is already on the evening with his friends, while his hands stay steady on the wood.
The news comes on. Top story: the government has recently introduced online universities, it sounds revolutionary, you’ll be able to study and graduate from home.
Dino stops for a moment and looks towards the wall, thinking “Huh, maybe that’s a chance. I should have studied more.” Then he tightens the tape and goes back to work.
Dino, like many, doesn’t know it yet, but the world of universities, anchored in solid traditions, is about to change. In the years that follow it will renew the way content is accessed and shared, transforming itself just as he is doing with that old olive tree.
Once that spring is over, Brisighella will turn scorching, like the rest of Italy: only grafts done properly will survive.
That same summer, the academic and research world will give birth to version 1.0 of Shibboleth, a technology closely bound to the SAML protocol. It will be grafted onto the universities’ LDAP environments and renew them, becoming a de facto standard for access management in the university world.
Like a scion worked by expert hands, it will bind itself to the deep roots of legacy systems, opening up scenarios that few could imagine back then.
More than twenty years later, that scion is still there. And someone has to graft Entra ID onto it.
Identity in a university: a typical ecosystem
Universities have always been a cradle of new ideas, especially when it comes to identity and access: they have to manage thousands of students, with high turnover from one year to the next, who access both long-standing services and new ones still being tried out.
In this context open technologies have always ruled the roost, with a philosophy of experimentation and sharing that led successful results to be replicated from one institution to another.
The typical ecosystem of the last twenty years can be summed up like this:
· an LDAP directory on a Unix base, in our experience very often OpenLDAP
· a SAML Identity Provider rooted in the LDAP directory
· a few legacy applications that speak LDAP directly
· a variety of SAML applications
Students’ identities live in LDAP and they access services mainly through SAML. LDAP isn’t our focus today, while SAML is worth a few words.
The acronym stands for Security Assertion Markup Language but, more than a language, it is a set of specifications that describes how to express security assertions in XML and how to exchange them between different systems. It relies on XML and digital certificates.
But what is an assertion? It is a package of information issued by an authority, in our case the Identity Provider, about a subject, usually a user. It can say that the user has authenticated, which attributes they have (name, role, enrolment in a course, what in the Microsoft world we call claims) and whether access to a resource is allowed or denied. It can contain all of this together, in a single signed document: a true monolith.
It is a protocol born in the golden age of browsers: the perspective is always that of a user in front of a web page, and it is the browser itself that acts as the courier.
When a student accesses a web application, they are redirected to the Identity Provider’s URL with an authentication request, often signed. They authenticate, the IdP retrieves the attributes from the LDAP directory and wraps them in a signed, and possibly encrypted, XML assertion. The browser delivers it to the application, usually with a POST, and the application verifies the signature, consumes the content and opens the session. In the most common flow, the IdP and the application never talk to each other directly.
In our scenario Shibboleth plays the part of the Identity Provider.
As we have seen, Shibboleth reaches its first version in 2003 with a simply stated goal: making it easier to share resources between organisations that use mutually incompatible authentication and authorisation systems. The underlying principle is to release attributes, not identity: the service doesn’t need to know who you are, it’s enough to know what you are, for example a student at a certain university. A choice made with privacy in mind, which will come in handy later: alongside the other attributes, each service receives for the same student an opaque identifier that is different and stable over time.
In Italy SAML is at home: it is the protocol behind SPID, the national public digital identity system, and, in the academic world, the one used by the IDEM federation. The name stands for IDEntity Management federato per l’accesso ai servizi: it is the Italian federation of digital identities for education and research, coordinated by GARR. IDEM works as a trusted third party: each university keeps its own directory and its own Identity Provider, while the federation publishes the metadata that states which IdPs and which services can be trusted. Students authenticate once at their own university and can access resources at other universities, such as digital libraries or journals, without the service provider ever seeing their password. The per-service opaque identifiers we mentioned are also provided for by the federation, in the form of the persistent NameID or the more recent pairwise-id: and it is precisely the persistent NameID that we will find at the heart of the graft with Entra ID.
This setup has not stayed confined to universities. We find the same pattern, with Linux/Unix, LDAP directories and Shibboleth, in some of the public bodies we have worked with too. It is on this ecosystem, mature, stable and proven, that sooner or later someone comes knocking with a new request.
Shibboleth and Entra ID: an open dialogue
Having understood the typical context, let’s now step into a real case and try to actually carry out the graft.
The environment belongs to a public body, but it mirrors the pattern seen earlier:
an OpenLDAP directory
a Shibboleth Identity Provider
a variety of applications federated in SAML 2
Note: Shibboleth also speaks OpenID Connect, through an official plugin, but in our case the protocol in play is SAML 2.
The mail system runs on Zimbra and the customer decides to migrate to Microsoft 365.
There is no Active Directory environment at all, and the wish is to access mail through SSO with the same credentials and in the same way as the other applications, avoiding unnecessary layers wherever possible.
We are called in to discuss the implementation.
The absence of an Active Directory immediately takes Microsoft’s on-premises federation solution out of the equation: Active Directory Federation Services (AD FS).
AD FS servers must be members of an AD DS domain: even though since 2016 they can query LDAP directories, they cannot work without an Active Directory behind them.
So we explore the possibility of a direct integration, and the SAML 2 route looks like the simplest and most linear one. The Microsoft documentation has a fairly clear article: Use a SAML 2.0 Identity Provider (IdP) for Single Sign On.
But before going any further, it’s better to look at the anatomy of a SAML token:
<samlp:Response Destination="https://login.microsoftonline.com/login.srf" InResponseTo="..." ...>
<saml:Issuer>https://idp.ente.example/idp/shibboleth</saml:Issuer>
<samlp:Status>
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
</samlp:Status>
<saml:Assertion ID="..." IssueInstant="..." Version="2.0">
<saml:Issuer>https://idp.ente.example/idp/shibboleth</saml:Issuer>
<ds:Signature> ... </ds:Signature>
<saml:Subject>
<saml:NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent">
KQ7WJ2XM5RT3BV6NP4CH2LD7ZSAE3FGY
</saml:NameID>
<saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<saml:SubjectConfirmationData Recipient="https://login.microsoftonline.com/login.srf"
NotOnOrAfter="..." InResponseTo="..."/>
</saml:SubjectConfirmation>
</saml:Subject>
<saml:Conditions NotBefore="..." NotOnOrAfter="...">
<saml:AudienceRestriction>
<saml:Audience>urn:federation:MicrosoftOnline</saml:Audience>
</saml:AudienceRestriction>
</saml:Conditions>
<saml:AuthnStatement AuthnInstant="..." SessionIndex="..."> ... </saml:AuthnStatement>
<saml:AttributeStatement>
<saml:Attribute Name="IDPEmail">
<saml:AttributeValue>mario.rossi@ente.example</saml:AttributeValue>
</saml:Attribute>
</saml:AttributeStatement>
</saml:Assertion>
</samlp:Response>As the example above shows, the token is a monolith in XML format: inside a Response there is an Assertion that holds all the information about the user.
The key piece of information is the NameID, the user’s unique identifier: Entra requires it, and this is the field on which the whole game is played.
Then there are the attributes, usually optional: first name, surname, email and so on.
Finally, the references to the parties involved: who issues the assertion (the Issuer, i.e. the IdP), who it is meant for (the Audience, i.e. the service provider), where it must be delivered and how long it is valid. All of it signed.
The Microsoft article is very precise about what the token must contain:
· NameID: must match the user’s ImmutableID in Entra, up to 64 alphanumeric characters; characters that are not HTML-safe must be encoded (for example “+” becomes “.2B”). The only supported format is persistent.
· IDPEmail: an attribute containing the user’s UserPrincipalName, in email format.
· Issuer: the IdP’s URI. If the tenant has multiple domains, the Issuer must match the URI configured for each domain.
· Signature: the assertion itself must be signed, with the signing certificate provided to Entra during configuration.
· Transport: HTTPS only. Entra uses POST for the authentication request and for the token, and Redirect for sign-out.
· Users: must already exist in Entra, with UPN equal to IDPEmail and OnPremisesImmutableId equal to the NameID.
Reading the lines about the NameID and the ImmutableID, the road looks downhill.
…Or so it seems.
Our instinct, however, seeing two worlds apparently so far apart, makes us suspect that something under the hood might not add up.
So we decide to set up a lab to verify the whole thing. A choice that would prove very wise!
We set up OpenLDAP, create the first accounts, make a few test calls: so far so good.
Then on to Shibboleth: we install it, configure the certificates and the service starts correctly.
Next we create the test tenant and add a verified public DNS domain to it: this is a requirement for federated logons, because Entra does not allow you to federate the default <mytenant>.onmicrosoft.com domain.
Time to connect the dots. On the Shibboleth side you can import Entra’s XML metadata file, while the other way round is less convenient: Entra does not read the IdP’s metadata, so issuer, endpoints and signing certificate have to be passed by hand, with PowerShell, in the command that converts the domain from managed to federated.
Then everything described in the article has to be configured, starting from the key piece of information: the NameID.
Here’s where the first knot shows up: Entra expects a string that never changes (the ImmutableID, already seen in Chapter 7). Where do we get it from in OpenLDAP?
First attempt, the simplest one: we dedicate an LDAP attribute to the ImmutableID and fill it in by hand for each user. At that point, we think, all it takes is to have Shibboleth read it and put it in the NameID to send it to Entra.
We start the configuration on the IdP: too bad the NameID isn’t among the normal outgoing fields. Where has it gone?
We will soon discover that in Shibboleth the NameID is not an ordinary attribute: it doesn’t go through the attribute filter that decides what to release, but has a mechanism all of its own, NameID generation.
So we start exploring the Shibboleth documentation, until the right article turns up. Given its nature as a unique key, the persistent NameID is treated as a special field and accepts only two strategies: computed or stored.
Computed. The identifier is obtained by calculating the hash of an input value to which a salt is added, two terms we’ll clarify shortly. No database is needed, but it is not reversible: you cannot change or revoke the identifier of a single user. It requires a stable, long-lived source attribute that is never reassigned to another subject and, most importantly, a secret salt: if the salt changes, all the identifiers change.
Stored. The identifier is generated at random and saved in a database. It can be changed or revoked per user, but it needs a highly available database, reachable from all the IdP nodes, and the documentation itself warns that making it reliable is not simple.
Note: the customer’s implementation does not include any database.
Before going further, it’s worth clarifying the two terms that will keep coming back from here on: hash and salt.
A hash is a function that takes input data of any length and returns a fixed-length sequence of characters, a sort of fingerprint.
It has two properties we care about. First: the same input always produces the same fingerprint. Second: you cannot go back from the fingerprint to the original data. It’s like blending a fruit: you can’t get the fruit back from the smoothie, but if you blend the same fruit the same way, you get the same smoothie.
The salt is a value added to the input before calculating the hash. In Shibboleth’s case it is a secret, usually a single one for the whole IdP, never shown to anyone. Whoever sees an identifier cannot rebuild it starting from the email address or the username, and only those who know the salt can redo the calculation and get the same result.
And here we come back to the graft. It is at the point of contact that the two identities must match, and the salt is the key element in making that happen: it decides whether the two parts, starting from the same user, end up with the same shape.
With the computed strategy, then, the identifier Shibboleth sends to Entra ID is not written down anywhere: it is recalculated at every login, and changing a single ingredient is enough for the user to become someone else.
With the terms clarified, let’s go back to the choice: without a database, the computed route is the only one that doesn’t introduce extra layers. The problem is understanding how the logic that turns the source LDAP field into the outgoing NameID works.
So we need to know the algorithm under the hood in order to control it.
Another search through the documentation and things become clearer.
There are three ingredients: the entityID of the service requesting access, the value of the source attribute and the secret salt.
A digest is calculated from them (usually SHA-1), encoded in Base64 or Base32, the latter recommended for new installations because it avoids the difference between upper and lower case. The result is an opaque value, unique per user and per service.
Ok, but how, exactly? The documentation lists the ingredients and gives a few hints, but doesn’t provide a precise recipe: which values go into the calculation, in what order, with which separators.
My colleague Alessandro, who ran the lab, then launches into a sort of reverse engineering in PowerShell: he combines the three elements, changes their order, tries different digests and encodings.
Each result is then compared with the NameID calculated by Shibboleth in the token.
After several failed attempts the answer turns up on a forum, and is then confirmed by this article that seemingly talks about something else: Moving away from StoredID.
Well hidden, in a passage of the page, it explains how to check that the calculated NameID is correct:
SELECT * FROM (
SELECT
c.localEntity,
c.peerEntity,
c.persistentId,
c.principalName,
c.localId,
c.creationDate,
TO_BASE64(
UNHEX(
SHA1(
CONCAT( c.peerEntity, '!', c.localId, '!', s.salt )
)
)
) as computedId
FROM shibpid c
JOIN salt s WHERE s.id=0
) generate_pids
WHERE persistentId <> computedId;On close inspection, the operation performed by the algorithm is plain to see: the entityID of the service (peerEntity), the value of the source attribute (localId) and the salt are concatenated, separated by a character never mentioned anywhere else in the documentation: “!”. The SHA-1 of this string is calculated and the result is encoded. In our case the service is Entra ID, and its entityID is the same value that appears in the Audience of the token seen earlier: urn:federation:MicrosoftOnline.
Without this detail, any attempt to combine and process the “ingredients” would never have produced the desired result. The final encoding is a different story: it is not hidden, but it must be chosen with care. The query uses Base64, while Base32 is recommended for new installations, and in that case only the last step changes. It is a choice that matters on the Entra side too: Base64 can produce characters that, as we’ve seen, must be encoded in the NameID, whereas Base32 uses only uppercase letters and digits. The NameID in the example seen earlier has exactly the shape of a Base32-encoded SHA-1.
With this important step clarified too, the flow becomes: LDAP field, Shibboleth algorithm (with the secret salt in the middle), Entra ImmutableID.
There is, however, one ingredient that depends solely on whoever designs the solution: the source LDAP field. As we’ve seen, it must be stable, long-lived and never reassigned to another subject. An email address or a username, which can change because of a correction to personal data or a change of role, are not good candidates: at the first change Shibboleth calculates an identifier different from the one registered in Entra ID, and the user is no longer found. Better a piece of data that stays with the person for life and doesn’t depend on their role.
And here the second issue pops up: when a domain registered in Entra ID is federated, creating an account in that domain requires the ImmutableID to be specified at the same time, a value that, at this point, only Shibboleth knows how to calculate.
In the lab, naturally, users are created by hand, with the identifier calculated by our colleague Alessandro.
So one user is prepared with the correct ImmutableID and one with the wrong one.
Then comes the test, the real litmus test: with the right identifier the login goes through, with the wrong one it doesn’t.
As for the failed login, my memory, years later, is of a rather unhelpful page, with no message that really pointed to where the problem lay.
Reading the documentation and the community threads again today, the code associated with this case is AADSTS51004 (“the user account does not exist in the directory”): Entra looks in the tenant for a user whose ImmutableID matches the NameID received and, if it doesn’t find one, denies access.
In any case, the message describes the symptom and not the cause, which is one more reason why the identifier calculation needs to be understood beforehand, not discovered afterwards.
At this point a question arises: who, or what, creates the users?
The customer has no Active Directory to synchronise, so Entra Connect isn’t part of the picture and there is nothing out of the box that brings the accounts from OpenLDAP to Entra ID.
A provisioning process is needed, one still to be built, that creates the user and assigns the right ImmutableID in the same operation.
And so, from a simple federation, we’ve moved on to designing a proper IAM flow.
Thinking through the options, there were three approaches on the table, from the most implicit to the most explicit:
· A PowerShell script that replicates Shibboleth’s algorithm and calculates the ImmutableID when the user is created.
· Integration with an IAM tool that manages the identity lifecycle.
· A dedicated LDAP attribute populated with the ImmutableID, then copied 1:1 to the cloud. In this case Shibboleth keeps calculating from the original field, so the two sources must be kept aligned, and if the salt changes the stored copy stops being valid.
The customer chose to integrate the process into its own IAM system, for consistency with the environment: calculating the identifier becomes a step in provisioning, not an add-on outside the flow.
The script was discarded for a very practical reason: there was no system to run PowerShell on.
The dedicated LDAP attribute remained the second choice, to be used only if the integration didn’t work out.
On the Entra side, both provisioning and deletion necessarily go through the Microsoft Graph API: when a person leaves the organisation, Entra ID is told through the same channel that was used to create them. Provisioning and deprovisioning, then, are two sides of the same process.
Then there’s the salt, and we’ve seen how critical it is.
The customer chose to keep it in its own vault, and not out of excess caution: as long as that value exists, every identifier can be recalculated, even after a server is replaced. If it is lost, or worse changed, the identifiers calculated from that moment on differ from those already in Entra ID, and at login no user is recognised any more.
Finally, the grey area, which needs to be stated clearly. Microsoft documents federation with third-party SAML IdPs, but on the same page it states that it does not offer support for the deployment, configuration and troubleshooting of those IdPs.
Everything around the NameID, the calculation and provisioning is therefore the work of whoever builds it, and of whoever maintains it afterwards.
At this point the graft has everything it needs to take hold vigorously and, over time, become a pillar of the integration. What remains is to understand what it teaches us.
What the graft teaches us
Let’s go back to the olive grove for a moment. Dino knows that a graft only takes if scion and rootstock are compatible and if the cambium of one matches that of the other. In our case the rootstock is the ecosystem that was already there, OpenLDAP and Shibboleth, with twenty-year-old roots; the scion is Entra ID; the cambium is the identifier: the same value, calculated twice, on one side and on the other. Hence, three things to take home.
The salt is what holds the graft together. The two identities match because someone, somewhere, knows a secret value. If that value changes or is lost, no user corresponds to themselves anymore: that’s why it isn’t rotated and isn’t forgotten, it is safeguarded, as the customer did by choosing its own vault. And it’s worth asking how much of what holds an identity together is written down somewhere and how much is only calculated: an identifier that exists only in the calculation can be lost without anyone noticing, whereas one saved in a dedicated attribute stays visible and verifiable, provided it is kept aligned with the source.
Provisioning is not an add-on, it is an active part of the graft. Federation, once the NameID is understood, is configured once and works. The hard part is everything around it: creating the user with the right identifier, deleting them through the same channel when they leave, keeping the sources aligned. It is the step that turned a simple federation into a proper IAM flow, and it is there that it is decided whether the graft holds over time.
Documented does not mean supported, nor complete. Microsoft describes federation with a third-party IdP but states that it does not support its configuration and troubleshooting. Shibboleth describes the ingredients but not the recipe: we found the “!” separator on a page that was talking about something else. In between there is a grey area, and there you work with the documentation, with testing and with those who have already got it wrong before you. That’s why it’s worth keeping what you have read separate from what you have seen in the lab, and writing it down in a way that stands the test of time: in a few years someone will have to maintain it, and will need to know not only how the graft was done, but why those choices were made.
On the dry-stone wall the little radio has long been switched off. Under the tape, in silence, two skins are learning to recognise each other.
Whether the work has been done well, only time will tell. And time, sooner or later, will bring someone else in front of that trunk, wondering where the cut was made, and why right there.





