def handle_type3(req, ntlm_message):
    '''Handle a Type3 NTLM message. Send it to the Domain Controller
    and get back the final authentication outcome.

    @req            The request that carried the message
    @ntlm_message   The actual Type3 message, in binary format
    '''
    
    proxy = cache.get_proxy(req.connection.id)
    try:
        user, domain = parse_ntlm_authenticate(ntlm_message)
        if not domain:
            domain = req.get_options().get('Domain', req.auth_name())
        result = proxy.authenticate(ntlm_message)
    except Exception, e:
        req.log_error('PYNTLM: Error when retrieving Type 3 message from server = %s' % str(e), apache.APLOG_CRIT)
        user, domain = 'invalid', 'invalid'
        result = False
    if not result:
        cache.remove(req.connection.id)
        req.log_error('PYNTLM: User %s/%s authentication for URI %s' % (
            domain,user,req.unparsed_uri))
        return handle_unauthorized(req)

    req.log_error('PYNTLM: User %s/%s has been authenticated to access URI %s' % (user,domain,req.unparsed_uri), apache.APLOG_NOTICE)
    set_remote_user(req, user, domain)
    result = check_authorization(req, user, proxy)
    cache.remove(req.connection.id)

    if not result:
        return apache.HTTP_FORBIDDEN

    req.connection.notes.add('NTLM_AUTHORIZED',req.user)
    return apache.OK
dataset/ETHPy150Open Legrandin/PyAuthenNTLM2/pyntlm.py/handle_type3/original