public string GetObjectIdFromSPN(string spn)
{
var odataQueryFilter = new Rest.Azure.OData.ODataQuery<ServicePrincipal>(s => s.ServicePrincipalNames.Contains(spn));
var sp = GraphClient.ServicePrincipals.List(odataQueryFilter).SingleOrDefault();
if (sp == null)
{
throw new InvalidOperationException(String.Format(ProjectResources.ServicePrincipalWithSPNDoesntExist, spn));
}
return sp.ObjectId;
}