要实现 LDAP 域登陆 ,因为需要使用多个域服务器登录(不同域账号分散) ,不知道怎么用自带的配置方法处理 ,所以自己修改了代码
seahub / seahub / base / accounts.py 修改
def check_password(self, raw_password):
"""
Returns a boolean of whether the raw_password was correct. Handles
encryption formats behind the scenes.
"""
# Backwards-compatibility check. Older passwords won't include the
# algorithm or salt.
# if '$' not in self.password:
# is_correct = (self.password == \
# get_hexdigest('sha1', '', raw_password))
# return is_correct
domain_list=["10.251.68.X","10.251.68.X","10.251.67.X","10.251.68.X","10.251.68.X"]
for domain in domain_list :
l=ldap.initialize('ldap://'+domain+':389')
l.protocol_version=ldap.VERSION2
try:
l.simple_bind_s(self.username,raw_password)#邮箱名与域账号一致
return True
except:
logger.error("err");
return False
#return (ccnet_threaded_rpc.validate_emailuser(self.username, raw_password) == 0)
来源:oschina
链接:https://my.oschina.net/u/615640/blog/511147