         '@xmlns:saml': XMLNS.SAML
         'saml:Issuer': issuer
         'samlp:Status':
-          'samlp:StatusCode': '@Value': 'urn:oasis:names:tc:SAML:2.0:status:Success'
+          'samlp:StatusCode': '@Value': status
     }, { headless: true }
     ).end()
 

      'samlp:SessionIndex': session_index
  .end()

create_logout_response = (issuer, status, in_response_to, destination) ->
  xmlbuilder.create(
    {'samlp:LogoutResponse':
        '@Destination': destination
        '@ID':  '_' + crypto.randomBytes(21).toString('hex')
        '@InResponseTo': in_response_to
        '@IssueInstant': (new Date()).toISOString()
        '@Version': '2.0'

        uri.query = sign_get_request deflated.toString('base64'), @private_key, relay_state
        cb null, url.format(uri)

    # Returns a redirect URL to confirm a successful logout.
    create_logout_response_url: (in_response_to, logout_url, cb) ->
      xml = create_logout_response @issuer, in_response_to, logout_url
      zlib.deflateRaw xml, (err, deflated) =>
        return cb err if err?
        uri = url.parse logout_url
        uri.query = sign_get_request deflated.toString('base64'), @private_key, undefined, true
        cb null, url.format(uri)

    # Returns XML metadata, used during initial SAML configuration
    create_metadata: (assert_endpoint) =>
