public static bool IsSubjectStoreType(this IdentityDescriptor identityDescriptor)
 {
     return(ReferenceEquals(identityDescriptor.IdentityType, IdentityConstants.System_License) ||
            ReferenceEquals(identityDescriptor.IdentityType, IdentityConstants.System_Scope) ||
            ReferenceEquals(identityDescriptor.IdentityType, IdentityConstants.System_ServicePrincipal) ||
            ReferenceEquals(identityDescriptor.IdentityType, IdentityConstants.System_WellKnownGroup) ||
            ReferenceEquals(identityDescriptor.IdentityType, IdentityConstants.System_CspPartner));
 }
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType.Equals(typeof(string)))
            {
                IdentityDescriptor descriptor = value as IdentityDescriptor;

                return(descriptor?.ToString() ?? string.Empty);
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }
 public static bool IsSystemScopeType(this IdentityDescriptor identityDescriptor)
 {
     return(identityDescriptor.IsIdentityType(IdentityConstants.System_Scope));
 }
 public static bool IsGroupScopeType(this IdentityDescriptor identityDescriptor)
 {
     return(identityDescriptor.IsIdentityType(IdentityConstants.GroupScopeType));
 }
 public static bool IsCspPartnerIdentityType(this IdentityDescriptor identityDescriptor)
 {
     return(identityDescriptor.IsIdentityType(IdentityConstants.CspPartnerIdentityType));
 }
 public static bool IsIdentityType(this IdentityDescriptor identityDescriptor, string identityType)
 {
     return(StringComparer.OrdinalIgnoreCase.Equals(identityDescriptor.IdentityType, identityType));
 }
 public static bool IsWindowsType(this IdentityDescriptor identityDescriptor)
 {
     return(identityDescriptor.IsIdentityType(IdentityConstants.WindowsType));
 }
 public static bool IsServerTestIdentityType(this IdentityDescriptor identityDescriptor)
 {
     return(identityDescriptor.IsIdentityType(IdentityConstants.ServerTestIdentity));
 }
 public static bool IsAggregateIdentityType(this IdentityDescriptor identityDescriptor)
 {
     return(identityDescriptor.IsIdentityType(IdentityConstants.AggregateIdentityType));
 }
 public static bool IsBindPendingType(this IdentityDescriptor identityDescriptor)
 {
     return(identityDescriptor.IsIdentityType(IdentityConstants.BindPendingIdentityType));
 }
 public static bool IsImportedIdentityType(this IdentityDescriptor identityDescriptor)
 {
     return(identityDescriptor.IsIdentityType(IdentityConstants.ImportedIdentityType));
 }
 public static bool IsClaimsIdentityType(this IdentityDescriptor identityDescriptor)
 {
     return(identityDescriptor.IsIdentityType(IdentityConstants.ClaimsType));
 }
 public static bool IsSystemServicePrincipalType(this IdentityDescriptor identityDescriptor)
 {
     return(identityDescriptor.IsIdentityType(IdentityConstants.System_ServicePrincipal));
 }
 public static bool IsUnknownIdentityType(this IdentityDescriptor identityDescriptor)
 {
     return(identityDescriptor.IsIdentityType(IdentityConstants.UnknownIdentityType));
 }
 public static bool IsSystemPublicAccessType(this IdentityDescriptor identityDescriptor)
 {
     return(identityDescriptor.IsIdentityType(IdentityConstants.System_PublicAccess));
 }
 public static bool IsSystemAccessControlType(this IdentityDescriptor identityDescriptor)
 {
     return(identityDescriptor.IsIdentityType(IdentityConstants.System_AccessControl));
 }
 public static bool IsUnauthenticatedIdentity(this IdentityDescriptor identityDescriptor)
 {
     return(identityDescriptor.IsIdentityType(IdentityConstants.UnauthenticatedIdentityType));
 }
 public static bool IsSystemCspPartnerType(this IdentityDescriptor identityDescriptor)
 {
     return(identityDescriptor.IsIdentityType(IdentityConstants.System_CspPartner));
 }
 /// <summary>
 /// true if the descriptor matches any of the passed types
 /// </summary>
 /// <param name="identityDescriptor"></param>
 /// <param name="identityTypes"></param>
 /// <returns></returns>
 public static bool IsIdentityType(this IdentityDescriptor identityDescriptor, IEnumerable <string> identityTypes)
 {
     return(identityTypes.Any(id => StringComparer.OrdinalIgnoreCase.Equals(identityDescriptor.IdentityType, id)));
 }
        internal static Identity FromXml(IServiceProvider serviceProvider, XmlReader reader)
        {
            Identity obj = new Identity();

            Debug.Assert(reader.NodeType == XmlNodeType.Element, "Expected a node.");

            bool empty = reader.IsEmptyElement;

            // Process the xml attributes
            if (reader.HasAttributes)
            {
                while (reader.MoveToNextAttribute())
                {
                    switch (reader.Name)
                    {
                    case "DisplayName":
                        obj.ProviderDisplayName = reader.Value;
                        break;

                    case "IsActive":
                        obj.IsActive = XmlConvert.ToBoolean(reader.Value);
                        break;

                    case "IsContainer":
                        obj.IsContainer = XmlConvert.ToBoolean(reader.Value);
                        break;

                    case "TeamFoundationId":
                        obj.Id = XmlConvert.ToGuid(reader.Value);
                        break;

                    case "UniqueName":
                        // We don't have this property on VSIdentity
                        //obj.UniqueName = reader.Value;
                        break;

                    case "UniqueUserId":
                        obj.UniqueUserId = XmlConvert.ToInt32(reader.Value);
                        break;

                    default:
                        // Allow attributes such as xsi:type to fall through
                        break;
                    }
                }
            }

            // Process the fields in Xml elements
            reader.Read();
            if (!empty)
            {
                while (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case "Attributes":
                        KeyValueOfStringString[] attributes = XmlUtility.ArrayOfObjectFromXml <KeyValueOfStringString>(serviceProvider, reader, "KeyValueOfStringString", false, KeyValueOfStringString.FromXml);
                        if (attributes != null && obj.Properties != null)
                        {
                            foreach (KeyValueOfStringString attribute in attributes)
                            {
                                obj.Properties[attribute.Key] = attribute.Value;
                            }
                        }
                        break;

                    case "Descriptor":
                        obj.Descriptor = IdentityDescriptor.FromXml(serviceProvider, reader);
                        break;

                    case "LocalProperties":
                        // Since we're only using the SOAP serializer for bootstrap, we won't support properties
                        //obj.m_localPropertiesSet = Helper.ArrayOfPropertyValueFromXml(serviceProvider, reader, false);
                        reader.ReadOuterXml();
                        break;

                    case "MemberOf":
                        obj.MemberOf = XmlUtility.ArrayOfObjectFromXml <IdentityDescriptor>(serviceProvider, reader, "IdentityDescriptor", false, IdentityDescriptor.FromXml);
                        break;

                    case "Members":
                        obj.Members = XmlUtility.ArrayOfObjectFromXml <IdentityDescriptor>(serviceProvider, reader, "IdentityDescriptor", false, IdentityDescriptor.FromXml);
                        break;

                    case "Properties":
                        // Since we're only using the SOAP serializer for bootstrap, we won't support properties
                        //obj.m_propertiesSet = Helper.ArrayOfPropertyValueFromXml(serviceProvider, reader, false);
                        reader.ReadOuterXml();
                        break;

                    default:
                        // Make sure that we ignore XML node trees we do not understand
                        reader.ReadOuterXml();
                        break;
                    }
                }
                reader.ReadEndElement();
            }
            return(obj);
        }
 public static bool IsTeamFoundationType(this IdentityDescriptor identityDescriptor)
 {
     return(identityDescriptor.IsIdentityType(IdentityConstants.TeamFoundationType));
 }