Mercurial > prosody-modules
changeset 870:13e645340767
Use singlematch to find user record in ldap.bind
author | Rob Hoelz <rob@hoelz.ro> |
---|---|
date | Mon, 10 Dec 2012 22:15:27 +0100 (2012-12-10) |
parents | ec791fd8ce87 |
children | e4a03e58f896 |
files | mod_lib_ldap/ldap.lib.lua |
diffstat | 1 files changed, 4 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_lib_ldap/ldap.lib.lua Mon Dec 10 22:14:28 2012 +0100 +++ b/mod_lib_ldap/ldap.lib.lua Mon Dec 10 22:15:27 2012 +0100 @@ -179,18 +179,15 @@ function _M.bind(username, password) local conn = _M.getconnection(); local filter = format('%s=%s', params.user.usernamefield, username); - local search_attrs = { + local who = _M.singlematch { attrs = params.user.usernamefield, base = params.user.basedn, - scope = 'subtree', - sizelimit = 1, filter = filter, }; - local who; - for dn in conn:search(search_attrs) do - module:log('debug', '_M.bind - who: %s', dn); - who = dn; + if who then + who = who.dn; + module:log('debug', '_M.bind - who: %s', who); end local conn, err = ldap.open_simple(params.hostname, who, password, params.use_tls);