问题描述
对于django项目,我设计了一个不同的登录页面。这里的用户将通过openldap登录。
我可以使用用户的uid id访问用户的完整信息,但是找不到如何验证密码。
是否需要对用户密码进行哈希处理并将其与ldap上的密码进行比较?还没有其他方法吗?谢谢
select datum,feiertag
bulk collect into tab_feiertage
from (
/* calculate moveable feast */
with hol as (
select calc_holidays(TO_NUMBER(in_year1)) as ostern
from dual )
/* Static holidays */
select to_date('01.01.'||in_year1,'DD.MM.YYYY') as datum,'Neujahr' as feiertag from hol union all
select to_date('06.01.'||in_year1,'3kings' as feiertag from hol union all
select to_date('08.03.'||in_year1,'Fraut' as feiertag from hol union all
select to_date('01.05.'||in_year1,'Arbeit' as feiertag from hol union all
select to_date('15.08.'||in_year1,'Himmel' as feiertag from hol union all
select to_date('03.10.'||in_year1,'Deu' as feiertag from hol union all
select to_date('31.10.'||in_year1,'Refo' as feiertag from hol union all
select to_date('01.11.'||in_year1,'Aller' as feiertag from hol union all
select to_date('25.12.'||in_year1,'Wh1' as feiertag from hol union all
select to_date('26.12.'||in_year1,'Wh2' as feiertag from hol union all
/* Changing holidays */
select ostern,'Ostern' as feiertag from hol union all
select ostern - INTERVAL '2' DAY as datum,'Karf' as feiertag from hol union all
select ostern - INTERVAL '3' DAY as datum,'Gruen' as feiertag from hol union all
select ostern + INTERVAL '1' DAY as datum,'Osterm' as feiertag from hol union all
select ostern + INTERVAL '39' DAY as datum,'Chimmel' as feiertag from hol union all
select ostern + INTERVAL '49' DAY as datum,'Pfingsts' as feiertag from hol union all
select ostern + INTERVAL '50' DAY as datum,'Pfingstm' as feiertag from hol union all
select ostern + INTERVAL '60' DAY as datum,'Fronlei' as feiertag from hol
);
解决方法
只是为了检查我使用的用户名和密码:
import ldap3
from ldap3.core.exceptions import LDAPException
def _ldap_login(username,password):
try:
with ldap3.Connection('enter_server',user=username,password=password) as conn:
print(conn.result["description"]) # "success" if bind is ok
return True
except LDAPException:
print('Unable to connect to LDAP server')
return False
_ldap_login("enter_username","enter_password")
以下是用于展示如何使用 ldap3
和 30 code examples 的 Tutorial: Introduction to ldap3。