def ldap_connect():
	from webnotes import get_details, set_ldap_connection
	server_details = get_details()

	connect, user_dn, base_dn = set_ldap_connection()
	filters =  "uid=*"

	new_created = [] 
	enabled_profiles = []

	try:
		#if authentication successful, get the full user data	
		connect.simple_bind_s(user_dn, server_details.get('pwd'))

	except ldap.LDAPError, e:
		connect.unbind_s()
Exemplo n.º 2
0
	def authenticate(self, user=None, pwd=None):
		from webnotes import get_details

		if not (user and pwd):	
			user, pwd = webnotes.form_dict.get('usr'), webnotes.form_dict.get('pwd')
		if not (user and pwd):
			self.fail('Incomplete login details')
		
		server_details = get_details()

		if user in ["Administrator", "administrator","*****@*****.**"]:
			self.check_if_enabled(user)
			self.user = self.check_password(user, pwd)
			status = True
		else:
			user, user_id, status, role = self.ldap_auth(user,pwd,server_details)
		
		if status and user not in ["Administrator", "administrator","*****@*****.**"]:
			self.check_profile(user, user_id, pwd, role)
			self.check_if_enabled(user)
		
		return user, status