Task
I needed to deploy console application that utilizes high-trust SharePoint authorization in multi-tenant environment. To be specific, I had about 10 tenants, SPSiteSubscription objects in farm. And I needed to assign permissions so that application was able to create new site collections.
Issue
Previously, when I had task to give permissions, I have used following articles and it worked like a charm:
https://msdn.microsoft.com/en-us/library/office/jj945118.aspx
https://msdn.microsoft.com/en-us/library/office/dn579380.aspx
The main problem here is that these articles provide following command for issuer registering:
$fullIssuerIdentifier = $specificIssuerId + '@' + $realm
New-SPTrustedSecurityTokenIssuer -Name $tokenIssuerName -Certificate $certificate -RegisteredIssuerName $fullIssuerIdentifier –IsTrustBroker
This approach is absolutely ok if your site collections are not linked to subscriptions. Then you just use farm realm.
This approach is ok for those cases when you need to provide permissions for only one tenant. You just use $web.Site.SiteSubscription.Id.ToString() as realm.
But if you need to provide permissions to more then one tenant, then you are in frustration. I had tried different approach before I found the right one.
For example, if you only register farm realm, then applications cannot be authenticated. Application gets 401 error.
The same if you only register with RegisteredIssuerName without realm, only issuerId, like New-SPTrustedSecurityTokenIssuer -Name $tokenIssuerName -Certificate $certificate -RegisteredIssuerName $issuerId –IsTrustBroker
When you try to register issuer for second subscription, you get an error:
New-SPTrustedSecurityTokenIssuer : Exception of type 'System.ArgumentException' was thrown.
Parameter name: newObj
At line:1 char:1
+ New-SPTrustedSecurityTokenIssuer -Name $issuerId -Certificate $certificate -Regi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (Microsoft.Share...rityTokenIssuer:SPCmdletNewTrustedSecurityTokenIssuer) [New-SPTrustedSecurityTokenIssu
er], ArgumentException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletNewTrustedSecurityTokenIssuer
Solutions
There are at least two possible solutions for that.
First, you have got an error because Name should be unique. On the other hand there is no any obligatory value rules for this parameter. It is up to you what name to provide. Target is that you can distinguish different issuers. So you can specify any distinguishing names for each tenant.
New-SPTrustedSecurityTokenIssuer -Name "tenant1" -Certificate $certificate -RegisteredIssuerName ($issuerId+"@"+$tenant1realm) –IsTrustBroker
New-SPTrustedSecurityTokenIssuer -Name "tenant2" -Certificate $certificate -RegisteredIssuerName ($issuerId+"@"+$tenant2realm) –IsTrustBroker
…
New-SPTrustedSecurityTokenIssuer -Name "tenantN" -Certificate $certificate -RegisteredIssuerName ($issuerId+"@"+$tenantNrealm) –IsTrustBroker
Another approach is to register certificate without issuer id specifying at all:
New-SPTrustedSecurityTokenIssuer –Name "Contoso Apps" -Certificate $certificate –IsTrustBroker
In this case only clientID and certificate have sense. Issuer id is not inspected in authentication procedure. This approach looks less secure, but requires less administration efforts.
No comments:
Post a Comment