def authentify(self, username, password):
     try:
         conn = self.connect()
         dn, attrs = self.search_user(username, conn=conn)
         self.connect(bind=False).simple_bind_s(dn, password)
         return self._get_or_create_user_from_ldap(dn, attrs, conn=conn)
     except ldap.LDAPError, e:
         current_app.log_exception(e)
Esempio n. 2
0
 def authentify(self, username, password):
     try:
         conn = self.connect()
         if self.options['append_username_domain'] and "@" not in username:
             username += "@" + self.options['append_username_domain']
         ldap_user = self.search_user(username, conn=conn)
         if ldap_user:
             dn, attrs = ldap_user
             self.connect(bind=False).simple_bind_s(dn, password)
             return self._get_or_create_user_from_ldap(dn, attrs, conn=conn)
     except ldap.LDAPError as e:
         current_app.log_exception(e)
Esempio n. 3
0
 def on_invoice(self, sender):
     if is_eu_country(sender.country):
         sender.is_eu_country = True
         if sender.customer:
             sender.eu_vat_number = sender.customer.eu_vat_number
         try:
             sender.eu_exchange_rate = self.service.get_exchange_rate(sender.country, sender.currency)
             if sender.tax_amount:
                 sender.eu_vat_amount = sender.tax_amount * sender.eu_exchange_rate
         except Exception as e:
             current_app.log_exception(e)
             sender.eu_exchange_rate = None
         if sender.eu_vat_number and self.options['invoice_customer_mention_message']:
             sender.customer_special_mention = self.options['invoice_customer_mention_message'].format(
                 number=sender.eu_vat_number)
     else:
         sender.is_eu_country = False