<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--
  ~ Copyright (c) 2010-2018 Evolveum and contributors
  ~
  ~ Licensed under the EUPL-1.2 or later.
  --><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:a="http://prism.evolveum.com/xml/ns/public/annotation-3" xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb" xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3" xmlns:tns="http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" elementFormDefault="qualified" jaxb:extensionBindingPrefixes="xjc" jaxb:version="3.0" targetNamespace="http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3">

    <xsd:annotation>
        <xsd:documentation>
            Capabilities schema.

            Defines resource capabilities such as ability to enable/disable account,
            ability to reset passwords, etc.

            Version: 3.9
            Recommended namespace prefix: cap
        </xsd:documentation>
        <xsd:appinfo>
            <!--  jaxb:globalBindings are specified indirectly by import from common-2 -->
            <a:defaultPrefix>cap</a:defaultPrefix>
        </xsd:appinfo>
    </xsd:annotation>

    <xsd:import namespace="http://midpoint.evolveum.com/xml/ns/public/common/common-3" schemaLocation="../common/common-3.xsd">
        <xsd:annotation>
            <xsd:documentation>
                Import of the common schema. Some datatypes are reused here.
            </xsd:documentation>
        </xsd:annotation>
    </xsd:import>

    <xsd:import namespace="http://prism.evolveum.com/xml/ns/public/query-3" schemaLocation="../query-3.xsd">
        <xsd:annotation>
            <xsd:documentation>
                Prism query.
            </xsd:documentation>
        </xsd:annotation>
    </xsd:import>

    <xsd:complexType name="CapabilityCollectionType">
        <xsd:annotation>
            <xsd:documentation>
                Collection of resource capabilities. Each element in this collection defines a specific resource capability.
                In the future, an extension element could be added here to cover deployment-specific capabilities. (If such need
                arises.)
            </xsd:documentation>
            <xsd:appinfo>
                <a:container/>
                <a:defaultNamespace>http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3</a:defaultNamespace>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:sequence>
            <xsd:element minOccurs="0" name="schema" type="tns:SchemaCapabilityType"/>
            <xsd:element minOccurs="0" name="discoverConfiguration" type="tns:DiscoverConfigurationCapabilityType"/>
            <xsd:element minOccurs="0" name="activation" type="tns:ActivationCapabilityType"/>
            <xsd:element minOccurs="0" name="references" type="tns:ReferencesCapabilityType">
                <xsd:annotation>
                    <xsd:appinfo>
                        <a:since>4.9</a:since>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:element>
            <xsd:element minOccurs="0" name="credentials" type="tns:CredentialsCapabilityType"/>
            <xsd:element minOccurs="0" name="liveSync" type="tns:LiveSyncCapabilityType"/>
            <xsd:element minOccurs="0" name="asyncUpdate" type="tns:AsyncUpdateCapabilityType"/>
            <xsd:element minOccurs="0" name="create" type="tns:CreateCapabilityType"/>
            <xsd:element minOccurs="0" name="read" type="tns:ReadCapabilityType"/>
            <xsd:element minOccurs="0" name="update" type="tns:UpdateCapabilityType"/>
            <xsd:element minOccurs="0" name="delete" type="tns:DeleteCapabilityType"/>
            <xsd:element minOccurs="0" name="testConnection" type="tns:TestConnectionCapabilityType"/>
            <xsd:element minOccurs="0" name="script" type="tns:ScriptCapabilityType"/>
            <xsd:element minOccurs="0" name="pagedSearch" type="tns:PagedSearchCapabilityType"/>
            <xsd:element minOccurs="0" name="countObjects" type="tns:CountObjectsCapabilityType"/>
            <xsd:element minOccurs="0" name="addRemoveAttributeValues" type="tns:AddRemoveAttributeValuesCapabilityType"/>
            <xsd:element minOccurs="0" name="auxiliaryObjectClasses" type="tns:AuxiliaryObjectClassesCapabilityType"/>
            <xsd:element minOccurs="0" name="runAs" type="tns:RunAsCapabilityType"/>
            <xsd:element minOccurs="0" name="behavior" type="tns:BehaviorCapabilityType"/>
        </xsd:sequence>
        <xsd:attribute name="id" type="xsd:long"/>
    </xsd:complexType>

    <!-- Abstract supertype -->

    <xsd:complexType abstract="true" name="CapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Abstract supertype for all (static schema) capabilities. It is in fact just a shortcut
                to introduce common "enabled" flag. As custom capabilities are expected to be in a
                dynamic schema this has probably very little conceptual value.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:sequence>
            <xsd:element minOccurs="0" ref="tns:enabled"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:element default="true" name="enabled" type="xsd:boolean">
        <xsd:annotation>
            <xsd:documentation>
                Element specifying whether the capability is enabled or disabled.
                Enabled capability work as usual (this is the default). Disabled capability
                acts as it is not there at all. This is used to disable undesirable
                native capabilities.
                Each capability definition should have this element. It is made a top-level
                element in this XSD definition to make that easier.
            </xsd:documentation>
        </xsd:annotation>
    </xsd:element>

    <!-- Concrete capabilities -->

    <xsd:complexType name="SchemaCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes capability to discover resource schema.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    <xsd:element name="schema" type="tns:SchemaCapabilityType"/>

    <xsd:complexType name="DiscoverConfigurationCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes capability to do configuration discovery, check and recommendation
                (`DiscoverConfigurationApiOp`).
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    <xsd:element name="discoverConfiguration" type="tns:DiscoverConfigurationCapabilityType"/>

    <xsd:complexType name="ActivationCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes capability to process activation data, which means
                enable/disable of accounts, dates for scheduled enable/disable
                and similar things related to make the account active.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                    <xsd:element minOccurs="0" name="status" type="tns:ActivationStatusCapabilityType">
                    </xsd:element>
                    <xsd:element minOccurs="0" name="validFrom" type="tns:ActivationValidityCapabilityType">
                    </xsd:element>
                    <xsd:element minOccurs="0" name="validTo" type="tns:ActivationValidityCapabilityType">
                    </xsd:element>
                    <xsd:element minOccurs="0" name="lockoutStatus" type="tns:ActivationLockoutStatusCapabilityType">
                    </xsd:element>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="activation" type="tns:ActivationCapabilityType"/>

    <xsd:complexType name="ActivationStatusCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes capability to provide activation status (e.g. account enable and disable).
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                    <xsd:element default="true" minOccurs="0" name="returnedByDefault" type="xsd:boolean"/>
                    <!-- TODO: "disable destroys password" -->
                    <xsd:element minOccurs="0" name="attribute" type="xsd:QName">
                        <xsd:annotation>
                            <xsd:documentation>
                                Name of the attribute to use for account enable/disable.
                                This is a configuration of simulated enable/disable capability.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element maxOccurs="unbounded" minOccurs="0" name="enableValue" type="xsd:string">
                        <xsd:annotation>
                            <xsd:documentation>
                                Value to set to the attribute when the account should be enabled.
                                This is a configuration of simulated enable/disable capability.

                                More than one value can be specified. All specified values will
                                be compared to the attribute when the activation status is read
                                from the resource (get operation). The value that matches will determine
                                the activation state. But only the first value will be used when
                                storing the activation state to the resource (add or modify operations).
                                All other values will be ignored.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element maxOccurs="unbounded" minOccurs="0" name="disableValue" type="xsd:string">
                        <xsd:annotation>
                            <xsd:documentation>
                                Value to set to the attribute when the account should be disabled.
                                This is a configuration of simulated enable/disable capability.

                                More than one value can be specified. All specified values will
                                be compared to the attribute when the activation status is read
                                from the resource (get operation). The value that matches will determine
                                the activation state. But only the first value will be used when
                                storing the activation state to the resource (add or modify operations).
                                All other values will be ignored.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element default="true" minOccurs="0" name="ignoreAttribute" type="xsd:boolean">
                        <xsd:annotation>
                            <xsd:documentation>
                                Flag that controls whether the original attribute should be ignored.

                                If set to true (or not present at all) the original attribute used as a source of
                                simulated capability is marked as "ignored" in the schema. If set to false then
                                the original attribute is still present in its original form in the schema.

                                This option is meaningful only for simulated enable/disable, i.e. in case that the
                                "attribute" element above is set.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="ActivationValidityCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes capability to provide activation validity dates (validFrom, validTo)
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                    <xsd:element default="true" minOccurs="0" name="returnedByDefault" type="xsd:boolean"/>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="ActivationLockoutStatusCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes capability to provide lockout status (e.g. account temporarily disabled due to many failed login attempts).
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                    <xsd:element default="true" minOccurs="0" name="returnedByDefault" type="xsd:boolean"/>
                    <xsd:element minOccurs="0" name="attribute" type="xsd:QName">
                        <xsd:annotation>
                            <xsd:documentation>
                                Name of the attribute to use for account lockout status.
                                This is a configuration of simulated lockout capability.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element maxOccurs="unbounded" minOccurs="0" name="normalValue" type="xsd:string">
                        <xsd:annotation>
                            <xsd:documentation>
                                Value to set to the attribute when the account is in a normal state (not locked out).
                                This is a configuration of simulated lockout capability.

                                More than one value can be specified. All specified values will
                                be compared to the attribute when the activation status is read
                                from the resource (get operation). The value that matches will determine
                                the activation state. But only the first value will be used when
                                storing the lockout state to the resource (add or modify operations).
                                All other values will be ignored.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element maxOccurs="unbounded" minOccurs="0" name="lockedValue" type="xsd:string">
                        <xsd:annotation>
                            <xsd:documentation>
                                Value to set to the attribute when the account is locked out.
                                This is a configuration of simulated lockout capability.

                                More than one value can be specified. All specified values will
                                be compared to the attribute when the activation status is read
                                from the resource (get operation). The value that matches will determine
                                the lockout state. But only the first value will be used when
                                storing the activation state to the resource (add or modify operations).
                                All other values will be ignored.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element default="true" minOccurs="0" name="ignoreAttribute" type="xsd:boolean">
                        <xsd:annotation>
                            <xsd:documentation>
                                Flag that controls whether the original attribute should be ignored.

                                If set to true (or not present at all) the original attribute used as a source of
                                simulated capability is marked as "ignored" in the schema. If set to false then
                                the original attribute is still present in its original form in the schema.

                                This option is meaningful only for simulated enable/disable, i.e. in case that the
                                "attribute" element above is set.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="CredentialsCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes capability to present credentials in a structured way.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                    <xsd:element minOccurs="0" name="password" type="tns:PasswordCapabilityType"/>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="credentials" type="tns:CredentialsCapabilityType"/>

    <xsd:complexType name="PasswordCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes capability to present password in a structured way.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                    <xsd:element default="true" minOccurs="0" name="returnedByDefault" type="xsd:boolean"/>
                    <xsd:element default="false" minOccurs="0" name="readable" type="xsd:boolean"/>
                    <!-- TODO: password expiration -->
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="LiveSyncCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes capability to detect changes in almost real time (live synchronization).
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                    <xsd:element minOccurs="0" name="preciseTokenValue" type="xsd:boolean">
                        <xsd:annotation>
                            <xsd:documentation>
                                If true then the connector ensures that the token value provided in each sync delta
                                is precise enough to guarantee correct restart of live sync after given delta.
                                (Some connectors provide token value of e.g. current timestamp, so they cannot distinguish
                                individual deltas. Others provide correct token values but do not guarantee correct ordering
                                of these deltas.)

                                EXPERIMENTAL
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="liveSync" type="tns:LiveSyncCapabilityType"/>

    <xsd:complexType name="AsyncUpdateCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes capability to process asynchronous updates. Note that this is currently supported only
                by the built-in AsyncUpdateConnector.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="asyncUpdate" type="tns:AsyncUpdateCapabilityType"/>

    <xsd:complexType abstract="true" name="AbstractWriteCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Base type for all write capabilities.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                    <xsd:element default="false" minOccurs="0" name="manual" type="xsd:boolean">
                        <xsd:annotation>
                            <xsd:documentation>
                                If set to true then there is NO online connection to the resource.
                                The operations are executed manually by a human operator. The resource
                                provides ability to execute the operations in an asynchronous way. But
                                this asynchronous operation contains a human in the loop.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="CreateCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes create capability.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:AbstractWriteCapabilityType">
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="create" type="tns:CreateCapabilityType"/>

    <xsd:complexType name="ReadCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes read capability.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                    <xsd:element default="false" minOccurs="0" name="cachingOnly" type="xsd:boolean">
                        <xsd:annotation>
                            <xsd:documentation>
                                If set to true then the resource does NOT have native read capability.
                                However, the resource suggests that the native read capability has to be
                                approximated by the use of midPoint caching.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element minOccurs="0" name="returnDefaultAttributesOption" type="xsd:boolean">
                        <xsd:annotation>
                            <xsd:documentation>
                                If set to true then the resource supports "return default attributes" option
                                when specifying the list of attributes to return.
                            </xsd:documentation>
                            <xsd:appinfo>
                                <a:since>3.9</a:since>
                            </xsd:appinfo>
                        </xsd:annotation>
                    </xsd:element>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="read" type="tns:ReadCapabilityType"/>

    <xsd:complexType name="UpdateCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes update capability.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:AbstractWriteCapabilityType">
                <xsd:sequence>
                    <xsd:element default="false" minOccurs="0" name="delta" type="xsd:boolean">
                        <xsd:annotation>
                            <xsd:documentation>
                                <p>
                                    If set to true then resource supports update operation that takes complete delta as an
                                    argument. Or in other words: the resource can execute complex updates
                                    that add/remove/replace values of several attributes in one operation.
                                </p>
                                <p>
                                    If set to false then resource cannot execute complex updates in one
                                    operation. Several operations may be needed, e.g. one operation to
                                    add values, separate operation to delete values. This may cause
                                    schema violations. E.g. deleting last value of a mandatory multi-valued
                                    attribute just to immediately add new value. Such operation may fail.
                                </p>
                            </xsd:documentation>
                            <xsd:appinfo>
                                <a:since>3.9</a:since>
                            </xsd:appinfo>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element default="false" minOccurs="0" name="addRemoveAttributeValues" type="xsd:boolean">
                        <xsd:annotation>
                            <xsd:documentation>
                                <p>
                                    If set to true then resource supports update operation that can add
                                    and remove individual attribute values.
                                </p>
                            </xsd:documentation>
                            <xsd:appinfo>
                                <a:since>4.0</a:since>
                            </xsd:appinfo>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element default="none" minOccurs="0" name="attributeContentRequirement" type="tns:AttributeContentRequirementType">
                        <xsd:annotation>
                            <xsd:documentation>
                                <p>
                                    Specifies requirement on attribute values that should be passed to an operation.
                                    E.g. whether only changed attributes should be passed to update operation
                                    or whether all the values should be passed.
                                </p>
                            </xsd:documentation>
                            <xsd:appinfo>
                                <a:since>4.1</a:since>
                                <a:experimental>true</a:experimental>
                            </xsd:appinfo>
                        </xsd:annotation>
                    </xsd:element>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    <xsd:element name="update" type="tns:UpdateCapabilityType"/>

    <xsd:simpleType name="AttributeContentRequirementType">
        <xsd:annotation>
            <xsd:documentation>
                Specifies requirement on attribute values that should be passed to an operation.
                E.g. whether only changed attributes should be passed to update operation
                or whether all the values should be passed.
            </xsd:documentation>
            <xsd:appinfo>
                <jaxb:typesafeEnumClass/>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="none">
                <xsd:annotation>
                    <xsd:documentation>
                        There is no special requirement for attribute content. E.g. only the changed attributes
                        should be passed into the update operation.
                    </xsd:documentation>
                    <xsd:appinfo>
                        <jaxb:typesafeEnumMember name="NONE"/>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:enumeration>
            <!-- Later:
                        available - values that are currently available (without significant overhead).
                        identifiers - all the identifiers should be passed (primary, secondary, ...)
               -->
            <xsd:enumeration value="all">
                <xsd:annotation>
                    <xsd:documentation>
                        The connector requires all the attributes of all attributes to be able to execute the operation.
                        MidPoint should take all necessary steps to retrieve needed to retrieve the values, even if that
                        means additional overhead.
                        E.g. update operation needs values for all attributes to be passed as "fake" modifications for
                        the connector to operate correctly.
                        All modification deltas will be replace deltas. Multi-value attribute deltas will contain all the values,
                        both all and new in a replace delta.
                    </xsd:documentation>
                    <xsd:appinfo>
                        <jaxb:typesafeEnumMember name="ALL"/>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:enumeration>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:complexType name="DeleteCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes delete capability.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:AbstractWriteCapabilityType">
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="delete" type="tns:DeleteCapabilityType"/>


    <xsd:complexType name="TestConnectionCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes capability to test connection to the resource once the connector is configured.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="testConnection" type="tns:TestConnectionCapabilityType"/>

    <xsd:complexType name="ScriptCapabilityHostType">
        <xsd:annotation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:sequence>
            <xsd:element name="type" type="c:ProvisioningScriptHostType"/>
            <xsd:element maxOccurs="unbounded" minOccurs="0" name="language" type="xsd:anyURI">
                <xsd:annotation>
                    <xsd:documentation>
                        Specifies the script language(s) supported on this host.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="ScriptCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes capability to execute scripts (short pieces of program) on the connector or resource.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                    <xsd:element maxOccurs="unbounded" name="host" type="tns:ScriptCapabilityHostType"/>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="script" type="tns:ScriptCapabilityType"/>

    <xsd:complexType name="PagedSearchCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                How to handle paged searches.
                Although deals primarily with GUI issues, may be useful for other kinds of access as well.

                If not present, paged searches are not enabled for this resource/kind/intent/objectClass.

                EXPERIMENTAL.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                    <xsd:element minOccurs="0" name="defaultSortField" type="xsd:QName">
                        <xsd:annotation>
                            <xsd:documentation>
                                If no sorting is specified by client (higher levels), use this field as the default.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element minOccurs="0" name="defaultSortDirection" type="q:OrderDirectionType">
                        <xsd:annotation>
                            <xsd:documentation>
                                If the defaultSortField is used, this element specified the sorting order
                                (ascending is the default).
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="pagedSearch" type="tns:PagedSearchCapabilityType"/>

    <xsd:complexType name="CountObjectsCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Ability to efficiently count objects.
                Although deals primarily with GUI issues, may be useful for other kinds of access as well.
                EXPERIMENTAL.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                    <xsd:element minOccurs="0" name="simulate" type="tns:CountObjectsSimulateType">
                        <xsd:annotation>
                            <xsd:documentation>
                                Strategy to simulate count operation using a different operation.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="countObjects" type="tns:CountObjectsCapabilityType"/>

    <xsd:simpleType name="CountObjectsSimulateType">
        <xsd:annotation>
            <xsd:documentation>
                Strategy to simulate count operation using a different operation.
            </xsd:documentation>
            <xsd:appinfo>
                <jaxb:typesafeEnumClass/>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="pagedSearchEstimate">
                <xsd:annotation>
                    <xsd:documentation>
                        Try a paged search with the page of one. Use the approximate number of entries
                        returned in search metadata as count approximation.
                    </xsd:documentation>
                    <xsd:appinfo>
                        <jaxb:typesafeEnumMember name="PAGED_SEARCH_ESTIMATE"/>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:enumeration>
            <xsd:enumeration value="sequentialSearch">
                <xsd:annotation>
                    <xsd:documentation>
                        Execute the actual search and sequentially count the entries.
                        WARNING: this may be very inefficient.
                    </xsd:documentation>
                    <xsd:appinfo>
                        <jaxb:typesafeEnumMember name="SEQUENTIAL_SEARCH"/>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:enumeration>
             </xsd:restriction>
    </xsd:simpleType>

    <xsd:complexType name="AddRemoveAttributeValuesCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Indication that ADD and REMOVE of attribute values is reliably supported.
                If this capability is not present or disabled, READ+REPLACE mode is assumed.
                (Can be overridden at the level of individual attributes via readReplaceMode property.)

                BEWARE: READ+REPLACE is currently supported for attributes only - not for subjectToObject associations.

                REMOVED:
                Use addRemoveAttributeValues element of Update capability instead.
            </xsd:documentation>
            <xsd:appinfo>
                <a:removed>true</a:removed>
                <a:removedSince>4.8</a:removedSince>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="addRemoveAttributeValues" type="tns:AddRemoveAttributeValuesCapabilityType">
        <xsd:annotation>
            <xsd:appinfo>
                <a:removed>true</a:removed>
                <a:removedSince>4.8</a:removedSince>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
    </xsd:element>

    <xsd:complexType name="AuxiliaryObjectClassesCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes capability to specify additional (auxiliary) object classes in addition to the
                primary object class.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="auxiliaryObjectClasses" type="tns:AuxiliaryObjectClassesCapabilityType"/>

    <xsd:complexType name="RunAsCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes capability to execute operations with specified identity.
            </xsd:documentation>
            <xsd:appinfo>
                <a:since>3.9</a:since>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                    <!-- TODO: settings whether authentication is required or whether this is just user switch (proxy) -->
                    <!-- TODO: if authentication is required then what credentials are needed? -->
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="BehaviorCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Container for various behavior-related capabilities.
            </xsd:documentation>
            <xsd:appinfo>
                <a:since>4.9.1</a:since>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                    <xsd:element minOccurs="0" name="lastLoginTimestamp" type="tns:LastLoginTimestampCapabilityType"/>
                </xsd:sequence>
                <xsd:attribute name="id" type="xsd:long"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="LastLoginTimestampCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                Describes capability of resource to provide last login timestamp.
            </xsd:documentation>
            <xsd:appinfo>
                <a:since>4.9.1</a:since>
                <a:container>true</a:container>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                    <xsd:element default="true" minOccurs="0" name="returnedByDefault" type="xsd:boolean"/>
                    <xsd:element minOccurs="0" name="attribute" type="xsd:QName">
                        <xsd:annotation>
                            <xsd:documentation>
                                Name of the attribute to use for account last login date.
                                This is a configuration of simulated capability.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element default="true" minOccurs="0" name="ignoreAttribute" type="xsd:boolean">
                        <xsd:annotation>
                            <xsd:documentation>
                                Flag that controls whether the original attribute should be ignored.

                                If set to true (or not present at all) the original attribute used as a source of
                                simulated capability is marked as "ignored" in the schema. If set to false then
                                the original attribute is still present in its original form in the schema.

                                This option is meaningful only for simulated lastLoginTimestamp, i.e. in case that the
                                "attribute" element above is set.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element minOccurs="0" name="format" type="xsd:string">
                        <xsd:annotation>
                            <xsd:documentation>
                                Option that controls how attribute value is parsed using SimpleDateFormat utility class.

                                This option is meaningful only for simulated lastLoginTimestamp, i.e. in case that the
                                "attribute" element above is set.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                </xsd:sequence>
                <xsd:attribute name="id" type="xsd:long"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="runAs" type="tns:RunAsCapabilityType"/>

    <xsd:complexType name="ReferencesCapabilityType">
        <xsd:annotation>
            <xsd:documentation>
                May specify either the native or simulated references.

                Native references are provided by the connector. In that case, the "type" item is empty.
                Also, this capability cannot be disabled by setting the "enabled" property to "false".
                MidPoint will ignore that setting, and the connector-provided references will still be there
                and will be used normally.

                Simulated references are provided by the engineer. In that case, the "type" item is used
                to specify how they should be simulated. The "enabled" property is used in the standard way.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container>true</a:container>
                <a:since>4.9</a:since>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:complexContent>
            <xsd:extension base="tns:CapabilityType">
                <xsd:sequence>
                    <xsd:element maxOccurs="unbounded" minOccurs="0" name="type" type="tns:SimulatedReferenceTypeDefinitionType"/>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="references" type="tns:ReferencesCapabilityType"/>

    <xsd:complexType name="SimulatedReferenceTypeDefinitionType">
        <xsd:annotation>
            <xsd:documentation>
                Definition of a simulated reference type.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container/>
                <a:since>4.9</a:since>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:sequence>
            <xsd:element name="name" type="xsd:QName">
                <xsd:annotation>
                    <xsd:documentation>
                        The name of the reference type. The namespace must be empty or "ri:".
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="subject" type="tns:SimulatedReferenceTypeParticipantType">
                <xsd:annotation>
                    <xsd:documentation>
                        Definition of the "subject" side of this reference type.
                        Typically, these are account-like kind of objects (e.g., user, inetOrgPerson, ...).
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="object" type="tns:SimulatedReferenceTypeParticipantType">
                <xsd:annotation>
                    <xsd:documentation>
                        Definition of the "subject" side of this reference type.
                        Typically, these are entitlement-like kind of objects (e.g., group, organizationalUnit, ...).
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="direction" type="c:ResourceObjectAssociationDirectionType">
                <xsd:annotation>
                    <xsd:documentation>
                        Direction of the primary binding. (This is the one denoted by "primaryBindingAttributeRef".)
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element default="true" minOccurs="0" name="explicitReferentialIntegrity" type="xsd:boolean">
                <xsd:annotation>
                    <xsd:documentation>
                        Whether you require midPoint to provide referential integrity for this reference type.

                        Used for resources that do not provide referential integrity by themselves, e.g. for OpenDJ with
                        default settings (i.e. with referential integrity plugin turned off).

                        For resources having referential integrity, e.g. for Active Directory, set this parameter to false.
                    </xsd:documentation>
                    <!-- TODO will we change the default value? -->
                </xsd:annotation>
            </xsd:element>
        </xsd:sequence>
        <xsd:attribute name="id" type="xsd:long"/>
    </xsd:complexType>
    <xsd:element name="simulatedReferenceType" type="tns:SimulatedReferenceTypeDefinitionType"/>

    <xsd:complexType name="SimulatedReferenceTypeParticipantType">
        <xsd:annotation>
            <xsd:documentation>
                Definition of a participant (subject or object) of a reference.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container/>
                <a:since>4.9</a:since>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:sequence>
            <xsd:element maxOccurs="unbounded" minOccurs="0" name="delineation" type="tns:SimulatedReferenceTypeParticipantDelineationType">
                <xsd:annotation>
                    <xsd:documentation>
                        Resource objects that participate as a subject or object of a simulated reference.
                        The binding attribute definition must be the same for all of them.
                        At least one delineation must be defined here.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="primaryBindingAttributeRef" type="xsd:QName">
                <xsd:annotation>
                    <xsd:documentation>
                        The attribute (on this participant's side) that provides the primary binding, i.e. the binding
                        that is updated when the reference value is created or deleted.

                        An example: ri:dn for the subject (inetOrgPerson), ri:members for the object (groupOfNames).

                        For the "receiving" side, i.e., the side that the binding points to, the attribute must be
                        a primary or secondary identifier (like ri:dn is for inetOrgPerson).
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element minOccurs="0" name="secondaryBindingAttributeRef" type="xsd:QName">
                <xsd:annotation>
                    <xsd:documentation>
                        The attribute (on this participant's side) that provides the secondary binding, i.e. the binding
                        that may be used for queries for performance reasons.

                        An example: ri:memberOf for the subject (inetOrgPerson), ri:dn for the object (groupOfNames).

                        For the "receiving" side, i.e., the side that the binding points to, the attribute must be
                        a primary or secondary identifier (like ri:dn for groupOfNames).

                        Optional. But it must be specified either for both sides of the reference, or for none of them.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element minOccurs="0" name="localItemName" type="xsd:QName">
                <xsd:annotation>
                    <xsd:documentation>
                        The name under which this reference is manifested on the participant resource object.

                        If not specified, the reference is not visible on the participant.

                        Limitation: Currently supported only for the subject side, and it is required there.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
        </xsd:sequence>
        <xsd:attribute name="id" type="xsd:long"/>
    </xsd:complexType>

    <xsd:complexType name="SimulatedReferenceTypeParticipantDelineationType">
        <xsd:annotation>
            <xsd:documentation>
                Delineates the boundary of eligible simulated reference participants.

                Similar to ResourceObjectTypeDelineationType, but with slight differences. Hence, we use a separate type.
            </xsd:documentation>
            <xsd:appinfo>
                <a:container/>
                <a:since>4.9</a:since>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:sequence>
            <xsd:element name="objectClass" type="xsd:QName">
                <xsd:annotation>
                    <xsd:documentation>
                        Object class (like ri:inetOrgPerson) for the participant.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element minOccurs="0" name="baseContext" type="c:ResourceObjectReferenceType">
                <xsd:annotation>
                    <xsd:documentation>
                        The definition of base context (resource object container). This object will be used
                        as a base for searches for the participants. Usually only the objects that are
                        hierarchically below the baseContext are returned by such a search.
                        E.g. this is used to specify LDAP organizationalUnit that contains users or groups
                        of particular type.
                    </xsd:documentation>
                    <xsd:appinfo>
                        <a:experimental>true</a:experimental>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:element>
            <xsd:element minOccurs="0" name="searchHierarchyScope" type="c:SearchHierarchyScopeType">
                <xsd:annotation>
                    <xsd:documentation>
                        Definition of search hierarchy scope. It specifies how "deep" the search should go
                        into the object hierarchy. It is only applicable to resources that support hierarchical
                        organization of objects (e.g. LDAP resources).
                    </xsd:documentation>
                    <xsd:appinfo>
                        <a:experimental>true</a:experimental>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:element>
            <!--<xsd:element name="filter" type="q:SearchFilterType" minOccurs="0" maxOccurs="unbounded">-->
            <!--    <xsd:annotation>-->
            <!--        <xsd:documentation>-->
            <!--            A filter that defines the object set.-->
            <!--        </xsd:documentation>-->
            <!--    </xsd:annotation>-->
            <!--</xsd:element>-->
            <xsd:element minOccurs="0" name="auxiliaryObjectClass" type="xsd:QName">
                <xsd:annotation>
                    <xsd:documentation>
                        Restriction of the participant to the specified auxiliary object class, if present.
                        Typically used if the binding attribute is defined in this class, like ri:uid for a posixAccount,
                        which is a member of a posixGroup.
                    </xsd:documentation>
                    <xsd:appinfo>
                        <a:experimental>true</a:experimental>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:element>
        </xsd:sequence>
        <xsd:attribute name="id" type="xsd:long"/>
    </xsd:complexType>
</xsd:schema>