Microsoft.Azure.Commands.Resources.Models.ActiveDirectory.ActiveDirectoryClient.GetObjectIdFromSPN C# (CSharp) Method

GetObjectIdFromSPN() public method

public GetObjectIdFromSPN ( string spn ) : string
spn string
return string
        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;
        }