<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

  <xs:simpleType name="BooleanTypeEnum">
    <xs:restriction base="xs:string">
      <xs:enumeration value="false"/>
      <xs:enumeration value="true"/>
      <xs:enumeration value="0"/>
      <xs:enumeration value="1"/>
      <xs:enumeration value="no"/>
      <xs:enumeration value="yes"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="AdScanTypeEnum">
    <xs:restriction base="xs:string">
      <xs:enumeration value="User"/>
      <xs:enumeration value="Computer"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="HourMinuteType">
    <xs:restriction base="xs:string">
      <xs:pattern value="[0-9]{2}:[0-9]{2}"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="DayTypeEnum">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Mon"/>
      <xs:enumeration value="Tue"/>
      <xs:enumeration value="Wed"/>
      <xs:enumeration value="Thu"/>
      <xs:enumeration value="Fri"/>
      <xs:enumeration value="Sat"/>
      <xs:enumeration value="Sun"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="guid">
    <xs:restriction base="xs:string">
      <xs:pattern value="[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="NameList">
    <xs:list itemType="xs:NCName"/>
  </xs:simpleType>

  <xs:simpleType name="LdapFilterProperyEnum">
    <xs:restriction base="xs:string">
      <xs:enumeration value="commonName"/>
      <xs:enumeration value="distinguishedName"/>
      <xs:enumeration value="samAccountName"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="M42ApiTokenLifetime">
    <xs:restriction base="xs:string">
      <xs:enumeration value="30 days"/>
      <xs:enumeration value="90 days"/>
      <xs:enumeration value="180 days"/>
      <xs:enumeration value="1 year"/>
      <xs:enumeration value="never"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="Matrix42-Ticket">
    <xs:restriction base="xs:string">
      <xs:enumeration value="30 days"/>
      <xs:enumeration value="90 days"/>
      <xs:enumeration value="180 days"/>
      <xs:enumeration value="1 year"/>
      <xs:enumeration value="never"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="TimezoneType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Dateline Standard Time"/>
      <xs:enumeration value="UTC-11"/>
      <xs:enumeration value="Hawaiian Standard Time"/>
      <xs:enumeration value="Alaskan Standard Time"/>
      <xs:enumeration value="Pacific Standard Time (Mexico)"/>
      <xs:enumeration value="Pacific Standard Time"/>
      <xs:enumeration value="US Mountain Standard Time"/>
      <xs:enumeration value="Mountain Standard Time (Mexico)"/>
      <xs:enumeration value="Mountain Standard Time"/>
      <xs:enumeration value="Central Standard Time"/>
      <xs:enumeration value="Central Standard Time (Mexico)"/>
      <xs:enumeration value="Central America Standard Time"/>
      <xs:enumeration value="Canada Central Standard Time"/>
      <xs:enumeration value="SA Pacific Standard Time"/>
      <xs:enumeration value="Eastern Standard Time (Mexico)"/>
      <xs:enumeration value="Eastern Standard Time"/>
      <xs:enumeration value="US Eastern Standard Time"/>
      <xs:enumeration value="Venezuela Standard Time"/>
      <xs:enumeration value="Paraguay Standard Time"/>
      <xs:enumeration value="Atlantic Standard Time"/>
      <xs:enumeration value="Central Brazilian Standard Time"/>
      <xs:enumeration value="SA Western Standard Time"/>
      <xs:enumeration value="Newfoundland Standard Time"/>
      <xs:enumeration value="E. South America Standard Time"/>
      <xs:enumeration value="Argentina Standard Time"/>
      <xs:enumeration value="SA Eastern Standard Time"/>
      <xs:enumeration value="Greenland Standard Time"/>
      <xs:enumeration value="Montevideo Standard Time"/>
      <xs:enumeration value="Bahia Standard Time"/>
      <xs:enumeration value="Pacific SA Standard Time"/>
      <xs:enumeration value="UTC-02"/>
      <xs:enumeration value="Mid-Atlantic Standard Time"/>
      <xs:enumeration value="Azores Standard Time"/>
      <xs:enumeration value="Cape Verde Standard Time"/>
      <xs:enumeration value="Morocco Standard Time"/>
      <xs:enumeration value="GMT Standard Time"/>
      <xs:enumeration value="UTC"/>
      <xs:enumeration value="Greenwich Standard Time"/>
      <xs:enumeration value="W. Europe Standard Time"/>
      <xs:enumeration value="Central Europe Standard Time"/>
      <xs:enumeration value="Romance Standard Time"/>
      <xs:enumeration value="Central European Standard Time"/>
      <xs:enumeration value="W. Central Africa Standard Time"/>
      <xs:enumeration value="Namibia Standard Time"/>
      <xs:enumeration value="Jordan Standard Time"/>
      <xs:enumeration value="GTB Standard Time"/>
      <xs:enumeration value="Middle East Standard Time"/>
      <xs:enumeration value="Syria Standard Time"/>
      <xs:enumeration value="South Africa Standard Time"/>
      <xs:enumeration value="FLE Standard Time"/>
      <xs:enumeration value="Turkey Standard Time"/>
      <xs:enumeration value="Israel Standard Time"/>
      <xs:enumeration value="Egypt Standard Time"/>
      <xs:enumeration value="Kaliningrad Standard Time"/>
      <xs:enumeration value="E. Europe Standard Time"/>
      <xs:enumeration value="Libya Standard Time"/>
      <xs:enumeration value="Arabic Standard Time"/>
      <xs:enumeration value="Arab Standard Time"/>
      <xs:enumeration value="Belarus Standard Time"/>
      <xs:enumeration value="Russian Standard Time"/>
      <xs:enumeration value="E. Africa Standard Time"/>
      <xs:enumeration value="Iran Standard Time"/>
      <xs:enumeration value="Arabian Standard Time"/>
      <xs:enumeration value="Azerbaijan Standard Time"/>
      <xs:enumeration value="Caucasus Standard Time"/>
      <xs:enumeration value="Russia Time Zone 3"/>
      <xs:enumeration value="Mauritius Standard Time"/>
      <xs:enumeration value="Georgian Standard Time"/>
      <xs:enumeration value="Afghanistan Standard Time"/>
      <xs:enumeration value="West Asia Standard Time"/>
      <xs:enumeration value="Pakistan Standard Time"/>
      <xs:enumeration value="Ekaterinburg Standard Time"/>
      <xs:enumeration value="India Standard Time"/>
      <xs:enumeration value="Sri Lanka Standard Time"/>
      <xs:enumeration value="Nepal Standard Time"/>
      <xs:enumeration value="Central Asia Standard Time"/>
      <xs:enumeration value="Bangladesh Standard Time"/>
      <xs:enumeration value="N. Central Asia Standard Time"/>
      <xs:enumeration value="Myanmar Standard Time"/>
      <xs:enumeration value="SE Asia Standard Time"/>
      <xs:enumeration value="North Asia Standard Time"/>
      <xs:enumeration value="North Asia East Standard Time"/>
      <xs:enumeration value="Singapore Standard Time"/>
      <xs:enumeration value="China Standard Time"/>
      <xs:enumeration value="W. Australia Standard Time"/>
      <xs:enumeration value="Taipei Standard Time"/>
      <xs:enumeration value="Ulaanbaatar Standard Time"/>
      <xs:enumeration value="Yakutsk Standard Time"/>
      <xs:enumeration value="Tokyo Standard Time"/>
      <xs:enumeration value="Korea Standard Time"/>
      <xs:enumeration value="Cen. Australia Standard Time"/>
      <xs:enumeration value="AUS Central Standard Time"/>
      <xs:enumeration value="E. Australia Standard Time"/>
      <xs:enumeration value="AUS Eastern Standard Time"/>
      <xs:enumeration value="West Pacific Standard Time"/>
      <xs:enumeration value="Tasmania Standard Time"/>
      <xs:enumeration value="Magadan Standard Time"/>
      <xs:enumeration value="Vladivostok Standard Time"/>
      <xs:enumeration value="Central Pacific Standard Time"/>
      <xs:enumeration value="Russia Time Zone 10"/>
      <xs:enumeration value="Russia Time Zone 11"/>
      <xs:enumeration value="New Zealand Standard Time"/>
      <xs:enumeration value="Fiji Standard Time"/>
      <xs:enumeration value="UTC+12"/>
      <xs:enumeration value="Kamchatka Standard Time"/>
      <xs:enumeration value="Tonga Standard Time"/>
      <xs:enumeration value="Samoa Standard Time"/>
      <xs:enumeration value="Line Islands Standard Time"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="LanguageId">
    <xs:restriction base="xs:string">
      <xs:pattern value="[A-Z]{2}" />
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="MultiLanguageEntry">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="Lang" type="LanguageId" use="required"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <xs:element name="DisplayName">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="MultiLanguageEntry" />
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="F4SD-Infrastructure-Configuration">
    <xs:complexType>
      <xs:all>
        <xs:element ref="Credentials" maxOccurs="1" minOccurs="1"/>
        <xs:element ref="DB-Connections" maxOccurs="1" minOccurs="1"/>
        <xs:element ref="DataHistory-DB" maxOccurs="1" minOccurs="1"/>
        <xs:element ref="F4SDAnalytics-DB" maxOccurs="1" minOccurs="0"/>
        <xs:element ref="ClientAgent" maxOccurs="1" minOccurs="1"/>
        <xs:element ref="Active-Directory" maxOccurs="1" minOccurs="1"/>
        <xs:element ref="Azure-AD" maxOccurs="1" minOccurs="0"/>
        <xs:element ref="Matrix42-WPM" maxOccurs="1" minOccurs="0"/>
        <xs:element ref="Nexthink" maxOccurs="1" minOccurs="0"/>
        <xs:element ref="Citrix" maxOccurs="1" minOccurs="0"/>
        <xs:element ref="Authorization" maxOccurs="1" minOccurs="0"/>
      </xs:all>
    </xs:complexType>
    <xs:key name="CredentialId">
      <xs:selector xpath="./Credentials/*"/>
      <xs:field xpath="@Name"/>
    </xs:key>
    <xs:key name="DbConnectionId">
      <xs:selector xpath="./DB-Connections/*"/>
      <xs:field xpath="@Name"/>
    </xs:key>
  </xs:element>

  <xs:element name="Credentials">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Credential" maxOccurs="unbounded" minOccurs="1"/>
      </xs:sequence>
    </xs:complexType>
    <xs:unique name="UniqueCredentials">
      <xs:selector xpath="./*"/>
      <xs:field xpath="@Name"/>
    </xs:unique>
  </xs:element>

  <xs:element name="Credential">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute name="Name" type="xs:NCName" use="required"/>
          <xs:attribute name="User" type="xs:string" use="required"/>
          <xs:attribute name="Domain" type="xs:string" use="optional"/>
          <xs:attribute name="Description" type="xs:string" use="optional"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

  <xs:element name="DB-Connections">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="SQL-Connection" maxOccurs="unbounded" minOccurs="1"/>
      </xs:sequence>
    </xs:complexType>
    <xs:unique name="UniqueSqlConnection">
      <xs:selector xpath="./*"/>
      <xs:field xpath="@Name"/>
    </xs:unique>
  </xs:element>

  <xs:element name="SQL-Connection">
    <xs:complexType>
      <xs:attribute name="Name" type="xs:NCName" use="required"/>
      <xs:attribute name="Credential" type="xs:NCName" use="required"/>
      <xs:attribute name="NativeAccount" type="BooleanTypeEnum" use="optional"/>
      <xs:attribute name="Server" type="xs:string" use="required"/>
      <xs:attribute name="Instance" type="xs:string" use="optional"/>
      <xs:attribute name="Database" type="xs:string" use="required"/>
      <xs:attribute name="Timeout" type="xs:nonNegativeInteger" use="optional"/>
    </xs:complexType>
    <xs:keyref name="SqlConnectionCredentialRef" refer="CredentialId">
      <xs:selector xpath="."/>
      <xs:field xpath="@Credential"/>
    </xs:keyref>
  </xs:element>

  <xs:element name="F4SDAnalytics-DB">
    <xs:complexType>
      <xs:attribute name="DB-Connection" type="xs:NCName" use="required"/>
      <xs:attribute name="EnableUserId" type="xs:boolean" use="optional"/>
      <xs:attribute name="SessionTimeout" type="xs:positiveInteger" use="optional" default="60"/>
      <xs:attribute name="CaseTimeout" type="xs:positiveInteger" use="optional" default="5"/>
      <xs:attribute name="SessionCheckInterval" type="xs:positiveInteger" use="optional" default="20"/>
      <xs:attribute name="CaseCheckInterval" type="xs:positiveInteger" use="optional" default="2"/>
    </xs:complexType>
    <xs:keyref name="F4SDAnalyticsDbSqlConnectionRef" refer="DbConnectionId">
      <xs:selector xpath="."/>
      <xs:field xpath="@DB-Connection"/>
    </xs:keyref>
  </xs:element>

  <xs:element name="DataHistory-DB">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Cleanup-Timeframe" maxOccurs="unbounded" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute name="DB-Connection" type="xs:NCName" use="required"/>
      <xs:attribute name="SearchForPhoneNumbers" type="xs:boolean" use="optional"/>
      <xs:attribute name="SearchWithLike" type="xs:boolean" use="optional"/>
      <xs:attribute name="DaysToCache" type="xs:positiveInteger" use="optional"/>
    </xs:complexType>
    <xs:keyref name="DataHistoryDbSqlConnectionRef" refer="DbConnectionId">
      <xs:selector xpath="."/>
      <xs:field xpath="@DB-Connection"/>
    </xs:keyref>
  </xs:element>

  <xs:element name="ClientAgent">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Scan-Timing" maxOccurs="1" minOccurs="0"/>
        <xs:element ref="Local-Account-Assignment" maxOccurs="unbounded" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute name="DB-Connection" type="xs:NCName" use="required"/>
      <xs:attribute name="Server-Url" type="xs:anyURI" use="required"/>
      <xs:attribute name="MaxDeviceAge" type="xs:nonNegativeInteger" use="required"/>
      <xs:attribute name="Organization" type="xs:string" use="required"/>
      <xs:attribute name="Api-Credential" type="xs:NCName" use="required"/>
      <xs:attribute name="Api-Path" type="xs:anyURI" use="optional"/>
    </xs:complexType>
    <xs:keyref name="ClientAgentDbSqlConnectionRef" refer="DbConnectionId">
      <xs:selector xpath="."/>
      <xs:field xpath="@DB-Connection"/>
    </xs:keyref>
    <xs:keyref name="ApiCredentialRef" refer="CredentialId">
      <xs:selector xpath="."/>
      <xs:field xpath="@Credential"/>
    </xs:keyref>
  </xs:element>


  <xs:element name="Local-Account-Assignment">
    <xs:complexType>
      <xs:attribute name="Domain" type="xs:string" use="required"/>
      <xs:attribute name="RegExFilter" type="xs:string" use="optional"/>
      <xs:attribute name="AccountMask" type="xs:string" use="optional"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="Azure-AD">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Azure-Tenant" maxOccurs="unbounded" minOccurs="1"/>
      </xs:sequence>
    </xs:complexType>
    <xs:unique name="UniqueTenants">
      <xs:selector xpath="./*"/>
      <xs:field xpath="@Domain"/>
    </xs:unique>
  </xs:element>

  <xs:element name="Azure-Tenant">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Azure-Filter-User" maxOccurs="1" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute name="Domain" type="xs:string" use="required"/>
      <xs:attribute name="TenantID" type="guid" use="required"/>
      <xs:attribute name="Credential" type="xs:NCName" use="required"/>
      <xs:attribute name="ScanIntuneDevices" type="xs:boolean" use="optional"/>
      <xs:attribute name="WithMobileDevices" type="xs:boolean" use="optional"/>
    </xs:complexType>
    <xs:keyref name="AzureTenantCredentialRef" refer="CredentialId">
      <xs:selector xpath="."/>
      <xs:field xpath="@Credential"/>
    </xs:keyref>
  </xs:element>

  <xs:element name="Azure-Filter-User">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute name="UseBetaEnpoint" type="xs:boolean" use="optional"/>
          <xs:attribute name="UseConsistencyLevelEventual" type="xs:boolean" use="optional"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

  <xs:complexType name="CitrixSystemType">
    <xs:attribute name="Name" type="xs:string" use="required"/>
    <xs:attribute name="SiteID" type="guid" use="optional"/>
    <xs:attribute name="Credential" type="xs:NCName" use="required"/>
  </xs:complexType>

  <xs:element name="Citrix">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Scan-Timing" maxOccurs="1" minOccurs="0"/>
        <xs:element ref="Citrix-Cloud-Tenant" maxOccurs="unbounded" minOccurs="0"/>
        <xs:element ref="Citrix-OnPrem-System" maxOccurs="unbounded" minOccurs="0"/>
      </xs:sequence>
    </xs:complexType>
    <xs:unique name="UniqueCitrixTenants">
      <xs:selector xpath="./*"/>
      <xs:field xpath="@Domain"/>
    </xs:unique>
  </xs:element>

  <xs:element name="Citrix-Cloud-Tenant">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="CitrixSystemType">
          <xs:attribute name="Name" type="xs:string" use="required"/>
          <xs:attribute name="Domain" type="xs:string" use="required"/>
          <xs:attribute name="TenantID" type="xs:string" use="required"/>
          <xs:attribute name="SiteID" type="guid" use="optional"/>
          <xs:attribute name="Credential" type="xs:NCName" use="required"/>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
    <xs:keyref name="CitrixTenantCredentialRef" refer="CredentialId">
      <xs:selector xpath="."/>
      <xs:field xpath="@Credential"/>
    </xs:keyref>
  </xs:element>

  <xs:element name="Citrix-OnPrem-System">
    <xs:complexType>
      <xs:attribute name="Name" type="xs:string" use="required"/>
      <xs:attribute name="Server" type="xs:string" use="required"/>
      <xs:attribute name="SiteID" type="guid" use="optional"/>
      <xs:attribute name="Credential" type="xs:NCName" use="required"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="Active-Directory">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Scan-Timing" maxOccurs="1" minOccurs="0"/>
        <xs:element ref="AD-Domains" maxOccurs="unbounded" minOccurs="0"/>
        <xs:element ref="AD-Scans" maxOccurs="unbounded" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute name="ScanPhoneNumbers" type="xs:boolean" use="optional"/>
    </xs:complexType>
    <xs:key name="AdDomainId">
      <xs:selector xpath="./AD-Domains/*"/>
      <xs:field xpath="@Name"/>
    </xs:key>
  </xs:element>

  <xs:element name="Scan-Timing">
    <xs:complexType>
      <xs:attribute name="ScanInterval" type="HourMinuteType" use="required"/>
      <xs:attribute name="ScanOffset" type="HourMinuteType" use="optional"/>
      <xs:attribute name="Timezone" type="TimezoneType" use="optional"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="Cleanup-Timeframe">
    <xs:complexType>
      <xs:attribute name="StartDay" type="DayTypeEnum" use="required"/>
      <xs:attribute name="StartTime" type="HourMinuteType" use="required"/>
      <xs:attribute name="StopDay" type="DayTypeEnum" use="optional"/>
      <xs:attribute name="StopTime" type="HourMinuteType" use="required"/>
      <xs:attribute name="Timezone" type="TimezoneType" use="optional"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="AD-Domains">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="AD-Domain" maxOccurs="unbounded" minOccurs="1"/>
      </xs:sequence>
    </xs:complexType>
    <xs:unique name="UniqueAdDomains">
      <xs:selector xpath="./*"/>
      <xs:field xpath="@Name"/>
    </xs:unique>
  </xs:element>

  <xs:element name="AD-Domain">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="AD-Server" maxOccurs="unbounded" minOccurs="1"/>
      </xs:sequence>
      <xs:attribute name="Name" type="xs:NCName" use="required"/>
      <xs:attribute name="FQDN" type="xs:string" use="required"/>
      <xs:attribute name="Credential" type="xs:NCName" use="required"/>
    </xs:complexType>
    <xs:unique name="UniqueAdServers">
      <xs:selector xpath="./*"/>
      <xs:field xpath="@FQDN"/>
    </xs:unique>
    <xs:keyref name="AdDomainCredentialRef" refer="CredentialId">
      <xs:selector xpath="."/>
      <xs:field xpath="@Credential"/>
    </xs:keyref>
  </xs:element>

  <xs:element name="AD-Server">
    <xs:complexType>
      <xs:attribute name="FQDN" type="xs:string" use="required"/>
      <xs:attribute name="UseSSL" type="BooleanTypeEnum" use="required"/>
      <xs:attribute name="Port" type="xs:integer" use="optional"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="AD-Scans">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="AD-Scan" maxOccurs="unbounded" minOccurs="1"/>
      </xs:sequence>
    </xs:complexType>
    <xs:unique name="UniqueAdScans">
      <xs:selector xpath="./*"/>
      <xs:field xpath="@Name"/>
    </xs:unique>
  </xs:element>

  <xs:element name="AD-Scan">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="AD-Scan-Node" maxOccurs="unbounded" minOccurs="1"/>
      </xs:sequence>
      <xs:attribute name="Name" type="xs:NCName" use="optional"/>
      <xs:attribute name="Type" type="AdScanTypeEnum" use="optional"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="AD-Scan-Node">
    <xs:complexType>
      <xs:attribute name="AD-Domain" type="xs:NCName" use="required"/>
      <xs:attribute name="Path" type="xs:string" use="required"/>
      <xs:attribute name="LDAP-Filter" type="xs:string" use="optional"/>
      <xs:attribute name="Filter-Property" type="LdapFilterProperyEnum" use="optional"/>
      <xs:attribute name="Wildcard-Filter" type="xs:string" use="optional"/>
      <xs:attribute name="RegEx-Filter" type="xs:string" use="optional"/>
    </xs:complexType>
    <xs:keyref name="AdScanNodeDomainRef" refer="AdDomainId">
      <xs:selector xpath="."/>
      <xs:field xpath="@AD-Domain"/>
    </xs:keyref>
  </xs:element>

  <xs:element name="Nexthink">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Scan-Timing" maxOccurs="1" minOccurs="0"/>
        <xs:element ref="Nxt-Portal" maxOccurs="unbounded" minOccurs="0"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="Nxt-Portal">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Nxt-Engine" maxOccurs="unbounded" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute name="Name" type="xs:NCName" use="required"/>
      <xs:attribute name="Address" type="xs:string" use="required"/>
      <xs:attribute name="Credential" type="xs:NCName" use="required"/>
      <xs:attribute name="IsCloud" type="BooleanTypeEnum" use="optional"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="Nxt-Engine">
    <xs:complexType>
      <xs:attribute name="Name" type="xs:NCName" use="required"/>
      <xs:attribute name="Address" type="xs:string" use="required"/>
      <xs:attribute name="Port" type="xs:nonNegativeInteger" use="optional"/>
    </xs:complexType>
  </xs:element>

  <xs:simpleType name="ShowDocumentCaseDialogOptions">
    <xs:restriction base="xs:string">
      <xs:enumeration value="always">
        <xs:annotation>
          <xs:documentation>Immer fragen</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="ifRequired">
        <xs:annotation>
          <xs:documentation>Fragen, wenn QuickAction und/oder Notizen vorhanden sind (Standard)</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="never">
        <xs:annotation>
          <xs:documentation>Niemals fragen</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="ActivityQueueFilterOptions">
    <xs:restriction base="xs:string">
      <xs:enumeration value="showAll">
        <xs:annotation>
          <xs:documentation>Alle anzeigen (Standard)</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="ticketsAndListedQueues">
        <xs:annotation>
          <xs:documentation>Alle Tickets / Incidents ohne Queue oder mit angegebener Queue</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="onlyListedQueues">
        <xs:annotation>
          <xs:documentation>Nur Tickets / Incidents mit angegebener Queue</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="onlyTickets">
        <xs:annotation>
          <xs:documentation>Nur Tickets / Incidents</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>

  <xs:element name="Matrix42-Ticket">
    <xs:complexType>
      <xs:attribute name="DisableAutomaticTimeTracking" type="xs:string" use="optional"/>
      <xs:attribute name="ShowDocumentCaseDialog" type="ShowDocumentCaseDialogOptions" use="optional" default="ifRequired"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="Queues">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Queue" maxOccurs="unbounded" minOccurs="1"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Queue">
    <xs:complexType>
      <xs:attribute name="QueueName" type="xs:string" use="required"/>
      <xs:attribute name="QueueID" type="guid" use="optional"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="Matrix42-WPM">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Matrix42-Ticket" minOccurs="0" maxOccurs="1" />
        <xs:element ref="DisplayName" minOccurs="0" maxOccurs="unbounded" />
        <xs:element ref="Queues" maxOccurs="1" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute name="Server" type="xs:string" use="required"/>
      <xs:attribute name="Credential" type="xs:NCName" use="required"/>
      <xs:attribute name="ClosedTicketHistory" type="xs:nonNegativeInteger" use="required"/>
      <xs:attribute name="DisplayName" type="xs:string" use="optional"/>
      <xs:attribute name="ApiTokenLifetime" type="M42ApiTokenLifetime" use="optional"/>
      <xs:attribute name="ActivityQueueFilter" type="ActivityQueueFilterOptions" use="optional" default="showAll"/>

    </xs:complexType>
    <xs:keyref name="M42WpmCredentialRef" refer="CredentialId">
      <xs:selector xpath="."/>
      <xs:field xpath="@Credential"/>
    </xs:keyref>
  </xs:element>

  <xs:element name="Authorization">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Membership-Groups" maxOccurs="1" minOccurs="0"/>
        <xs:element ref="Roles" maxOccurs="1" minOccurs="0"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="Membership-Groups">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Membership-Groups-AD" maxOccurs="unbounded" minOccurs="0"/>
        <xs:element ref="Membership-Groups-Matrix42" maxOccurs="unbounded" minOccurs="0"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="Membership-Groups-AD">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Membership-Group-AD" maxOccurs="unbounded" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute name="Domain" type="xs:NCName" use="required"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="Membership-Group-AD">
    <xs:complexType>
      <xs:attribute name="Name" type="xs:NCName" use="required"/>
      <xs:attribute name="Account" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="Roles">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Role" maxOccurs="unbounded" minOccurs="1"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="Role">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="GroupRef" maxOccurs="unbounded" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute name="Name" type="xs:NCName" use="required"/>
      <xs:attribute name="Group" type="xs:NCName" use="optional"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="GroupRef">
    <xs:complexType>
      <xs:attribute name="Name" type="xs:NCName" use="required"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="Membership-Groups-Matrix42">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Membership-Group-Matrix42" maxOccurs="unbounded" minOccurs="0"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="Membership-Group-Matrix42">
    <xs:complexType>
      <xs:attribute name="Name" type="xs:NCName" use="required"/>
      <xs:attribute name="RoleName" type="xs:string" use="required"/>
      <xs:attribute name="RoleID" type="guid" use="optional"/>
    </xs:complexType>
  </xs:element>

</xs:schema>
