EndpointIdentity does not contain a definition for CreateUpnIdentity

Viewed 1607

When converting a class library from .NET Framework 4.6.2 to .NET Standard 2.0 i get this error: "EndpointIdentity does not contain a definition for CreateUpnIdentity". The change that i needed to make is install System.ServiceModel.Primitives. But somehow that library does not contain definition for "CreateUpnIdentity".

static EndpointIdentity CreateIdentity()
        {
            WindowsIdentity self = WindowsIdentity.GetCurrent();
            SecurityIdentifier sid = self.User;
            EndpointIdentity identity = null;
            if (sid.IsWellKnown(WellKnownSidType.LocalSystemSid) ||
                sid.IsWellKnown(WellKnownSidType.NetworkServiceSid) ||
                sid.IsWellKnown(WellKnownSidType.LocalServiceSid))
            {
                identity = EndpointIdentity.CreateSpnIdentity(
                    String.Format(CultureInfo.InvariantCulture, "host/{0}", GetMachineName()));
            }
            else
            {
                // Need an UPN string here
                identity = EndpointIdentity.CreateUpnIdentity(self.Name);
            }
            return identity;
        }
2 Answers
Related