domain = req.get_options()['Domain'] pdc = req.get_options()['PDC'] bdc = req.get_options().get('BDC', False) except KeyError, e: req.log_error('PYNTLM: Incorrect configuration for pyntlm = %s' % str(e), apache.APLOG_CRIT) raise ntlm_challenge = None for server in (pdc, bdc): if not server: continue try: proxy = NTLM_Proxy(server, domain) ntlm_challenge = proxy.negotiate(type1) except Exception, e: req.log_error('PYNTLM: Error when retrieving Type 2 message from DC(%s) = %s' % (server,str(e)), apache.APLOG_CRIT) if ntlm_challenge: break proxy.close() else: raise RunTimeError return (proxy, ntlm_challenge) def handle_type1(req, ntlm_message): '''Handle a Type1 NTLM message. Send it to the Domain Controller and get back the challenge (the Type2 NTLM message that is). @req The request that carried the message @ntlm_message The actual Type1 message, in binary format ''' # Cache clean up: everything older than 60 seconds is removed now = int(time.time()) mutex.acquire() for id, conn in cache.items():