SOAP를 통한 SQL Server 인증

Microsoft SQL Server의 이후 버전에서는 이 기능이 제거됩니다. 새 개발 작업에서는 이 기능을 사용하지 않도록 하고, 현재 이 기능을 사용하는 응용 프로그램은 수정하십시오.

SQL Server에서 네이티브 XML 웹 서비스를 사용할 경우 다음 유형의 보안 주체를 사용하여 보안을 관리할 수 있습니다.

  • Windows 사용자, 그룹 계정 또는 둘 다

  • SQL Server 로그인

HTTP 끝점 인증에 Windows 계정을 사용할 때는 추가 SOAP 인증 헤더가 필요 없습니다. HTTP 끝점 인증에 대한 자세한 내용은 끝점 인증 유형GRANT 끝점 사용 권한(Transact-SQL)를 참조하십시오.

그러나 SQL Server 로그인을 사용할 때는 클라이언트 응용 프로그램에서 포함할 SOAP 인증에 대한 WS-Security(Web Services Security) 헤더를 추가로 구현하고 서버에 SQL Server 로그인 정보를 제출해야 합니다.

SQL Server 로그인의 SOAP 인증에는 모든 HTTP 인증 유형을 사용할 수 있습니다. 또한 HTTP 계층에서 인증하는 데 사용되는 사용자 계정에는 로컬 서버에 대한 Windows 액세스만 필요하며 SQL Server 로그인은 필요 없습니다.

[!참고]

SOAP를 통한 SQL Server 기반 인증의 경우 끝점의 LOGIN_TYPE 옵션을 혼합 모드로 구성해야 합니다. 즉, LOGIN_TYPE=MIXED를 지정합니다. 또한 끝점을 혼합 모드로 운영하려면 SSL(Secure Sockets Layer) 채널을 통해 서비스를 제공하도록 끝점을 구성해야 합니다. 자세한 내용은 CREATE ENDPOINT(Transact-SQL)를 참조하십시오.

WS-Security 헤더를 사용하여 SQL Server 로그인 인증(혼합 모드만 해당)

WS-Security는 웹 서비스의 보안에 유용하도록 SOAP 메시지 구조를 확장하기 위해 제안된 사양입니다. 필요에 따라 WS-Security를 기반으로 SOAP 메시지 구조를 확장하여 SOAP 메시지 내에서 직접 SOAP 클라이언트와 SQL Server 인스턴스 간에 자격 증명과 토큰을 전달할 수 있는 인증 메커니즘을 제공할 수 있습니다.

다음 조건에 해당하면 WS-Security 헤더를 사용하여 SQL Server 사용자 및 암호 정보를 SOAP 클라이언트 응용 프로그램의 일부로 제공할 수 있습니다.

  • SQL Server 인스턴스가 혼합 모드로 설치되었습니다. 즉, Windows 로그인과 SQL Server 로그인이 모두 지원됩니다.

  • 끝점 설정이 다음과 같습니다.

    • LOGIN_TYPE = MIXED

    • PORTS=(SSL). SSL 유형 포트가 지정되었습니다.

  • SQL Server 로그인 등 Windows 로그인에 속하지 않은 사용자에게 끝점 권한이 부여되었습니다.

SOAP 요청에 WS-Security 헤더가 포함된 경우 헤더의 자격 증명은 끝점에 대해 HTTP 기반 인증이 수행될 때 사용된 자격 증명을 모두 무시합니다.

SQL Server 인증에 WS-Security 헤더 사용

SQL Server 인스턴스에 보내는 SOAP 요청에 WS-Security 헤더를 사용하여 다음을 지원할 수 있습니다.

  • SQL-Auth(SQL Server 권한 부여) 자격 증명 전송

  • 만료된 SQL Server 암호 처리

SQL-Auth 자격 증명 전송

다음 예에서는 SQL Server 인스턴스에 보내는 SOAP 요청에 WS-Security 헤더를 사용하여 SQL-Auth(SQL Server 권한 부여) 자격 증명을 전송하는 방법을 보여 줍니다.

<SOAP-ENV:Header>
            <wsse:Security  xmlns:wsse=
                        "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
            <wsse:UsernameToken>
                        <wsse:Username>JohnDoe</wsse:Username>
            <wsse:Password Type=
                        "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">pass-word1</wsse:Password>
            </wsse:UsernameToken>
            </wsse:Security>
</SOAP-ENV:Header>

이 예에서 <wsse:UserNameToken> 요소는 다음 두 하위 요소를 포함하는 데 사용됩니다.

  • SQL Server 사용자 이름을 포함하는 <wsse:Username> 요소

  • 선택적 Type 특성이 "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"의 값으로 설정된 <wsse:Password> 요소. 이 요소는 사용자의 암호 텍스트를 포함하는 데 사용됩니다.

[!참고]

SQL Server 및 HTTP SOAP 끝점에 혼합 모드가 지원되는 경우 SSL 포트가 있어야 사용자 자격 증명의 최소 암호화를 제공할 수 있습니다.

만료된 SQL Server 암호 처리

SQL Server에서는 암호 만료 기능을 제공합니다. 로그인을 시도하는 동안 서버에서 사용자 암호가 만료된 것을 확인하면 암호 기능에 따라 클라이언트가 사용자의 이전 암호와 새 암호를 모두 제공해야 로그인 프로세스가 성공적으로 완료됩니다.

이 기능을 지원하도록 클라이언트를 업데이트하려면 다음 WS-Security 헤더를 템플릿 예제로 사용하여 이 프로세스를 완료할 수 있습니다.

<SOAP-ENV:Header>
 <wsse:Security  xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
            <wsse:UsernameToken>
                        <wsse:Username>JohnDoe</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">pass-word2</wsse:Password>
            <sql:OldPassword Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText" xmlns:sql="https://schemas.microsoft.com/sqlserver/2004/SOAP">pass-word1</sql:OldPassword>
            </wsse:UsernameToken>
 </wsse:Security>
</SOAP-ENV:Header>

SOAP 세션의 일부로 암호 변경을 수행할 수도 있습니다. 암호 변경 요청은 새 세션이 시작될 때만 인식됩니다.

예를 들어 새 SOAP 세션의 일부로 암호를 변경하려면 <SOAP-ENV:Header> 섹션에 다음을 추가합니다.

<sqloptions:sqlSession xmlns:sqloptions="https://schemas.microsoft.com/sqlserver/2004/SOAP/Options" initiate="true"/>

자세한 내용은 SOAP 세션 작업을 참조하십시오.

또한 <wsse:UserNameToken> 요소가 조금 수정되어 이전의 사용자 자격 증명 보내기 예제와 약간 다른 다음 세 하위 요소를 포함합니다.

  • SQL Server 사용자 이름을 포함하는 <wsse:Username> 요소

  • 선택적 Type 특성이 "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"의 값으로 설정된 <wsse:Password> 요소. 이 요소는 사용자의 새 암호 텍스트를 포함하는 데 사용됩니다.

  • Type 특성이 "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"의 값으로 설정된 <sql:OldPassword> 요소. 이 요소는 사용자의 이전 암호 텍스트를 포함하는 데 사용됩니다.

WS-Security 헤더에 대한 XML 스키마

다음은 SQL Server에서만 구현되는 WS-Security 헤더에 대한 스키마의 일부분입니다.

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sql="https://schemas.microsoft.com/sqlserver/2004/SOAP" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
  <xsd:import namespace="https://schemas.microsoft.com/sqlserver/2004/SOAP" />
  <xsd:annotation>
    <xsd:documentation xml:lang="en">(c) Copyright 2004, Microsoft Corporation The following schema for Microsoft SQL Server is presented in XML format and is for informational purposes only. Microsoft Corporation ("Microsoft") may have trademarks, copyrights, or other intellectual property rights covering subject matter in the schema. Microsoft does not make any representation or warranty regarding the schema or any product or item developed based on the schema. The schema is provided to you on an AS IS basis. Microsoft disclaims all express, implied and statutory warranties, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, and freedom from infringement. Without limiting the generality of the foregoing, Microsoft does not make any warranty of any kind that any item developed based on the schema, or any portion of the schema, will not infringe any copyright, patent, trade secret, or other intellectual property right of any person or entity in any country. It is your responsibility to seek licenses for such intellectual property rights where appropriate. MICROSOFT SHALL NOT BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SCHEMA, INCLUDING WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL (INCLUDING ANY LOST PROFITS), PUNITIVE OR SPECIAL DAMAGES, WHETHER OR NOT MICROSOFT HAS BEEN ADVISED OF SUCH DAMAGES.</xsd:documentation> 
  </xsd:annotation>
  <xsd:element name="Security">
    <xsd:complexType>
      <xsd:sequence minOccurs="1" maxOccurs="1">
        <xsd:element name="UsernameToken">
          <xsd:complexType>
            <xsd:sequence minOccurs="1" maxOccurs="1">
              <xsd:element name="Username" type="xsd:string" />
              <xsd:element name="Password">
                <xsd:complexType>
                  <xsd:simpleContent>
                    <xsd:extension base="xsd:string">
                      <xsd:attribute name="Type" type="xsd:anyURI" />
                    </xsd:extension>
                  </xsd:simpleContent>
                </xsd:complexType>
              </xsd:element>
              <xsd:element name="OldPassword" type="sql:OldPassword" minOccurs="0" />
            </xsd:sequence>
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sql="https://schemas.microsoft.com/sqlserver/2004/SOAP" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="https://schemas.microsoft.com/sqlserver/2004/SOAP">
  <xsd:annotation>
    <xsd:documentation xml:lang="en">(c) Copyright 2004, Microsoft Corporation The following schema for Microsoft SQL Server is presented in XML format and is for informational purposes only. Microsoft Corporation ("Microsoft") may have trademarks, copyrights, or other intellectual property rights covering subject matter in the schema. Microsoft does not make any representation or warranty regarding the schema or any product or item developed based on the schema. The schema is provided to you on an AS IS basis. Microsoft disclaims all express, implied and statutory warranties, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, and freedom from infringement. Without limiting the generality of the foregoing, Microsoft does not make any warranty of any kind that any item developed based on the schema, or any portion of the schema, will not infringe any copyright, patent, trade secret, or other intellectual property right of any person or entity in any country. It is your responsibility to seek licenses for such intellectual property rights where appropriate. MICROSOFT SHALL NOT BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SCHEMA, INCLUDING WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL (INCLUDING ANY LOST PROFITS), PUNITIVE OR SPECIAL DAMAGES, WHETHER OR NOT MICROSOFT HAS BEEN ADVISED OF SUCH DAMAGES.</xsd:documentation> 
  </xsd:annotation>
  <xsd:complexType name="OldPassword">
    <xsd:simpleContent>
      <xsd:extension base="xsd:string">
        <xsd:attribute name="Type" type="xsd:anyURI" />
      </xsd:extension>
    </xsd:simpleContent>
  </xsd:complexType>
</xsd:schema>