Mercurial > prosody-modules
comparison mod_lib_ldap/ldap.lib.lua @ 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 |
| parents | ec791fd8ce87 |
| children | e4a03e58f896 |
comparison
equal
deleted
inserted
replaced
| 869:ec791fd8ce87 | 870:13e645340767 |
|---|---|
| 177 | 177 |
| 178 -- XXX consider renaming this...it doesn't bind the current connection | 178 -- XXX consider renaming this...it doesn't bind the current connection |
| 179 function _M.bind(username, password) | 179 function _M.bind(username, password) |
| 180 local conn = _M.getconnection(); | 180 local conn = _M.getconnection(); |
| 181 local filter = format('%s=%s', params.user.usernamefield, username); | 181 local filter = format('%s=%s', params.user.usernamefield, username); |
| 182 local search_attrs = { | 182 local who = _M.singlematch { |
| 183 attrs = params.user.usernamefield, | 183 attrs = params.user.usernamefield, |
| 184 base = params.user.basedn, | 184 base = params.user.basedn, |
| 185 scope = 'subtree', | |
| 186 sizelimit = 1, | |
| 187 filter = filter, | 185 filter = filter, |
| 188 }; | 186 }; |
| 189 local who; | 187 |
| 190 | 188 if who then |
| 191 for dn in conn:search(search_attrs) do | 189 who = who.dn; |
| 192 module:log('debug', '_M.bind - who: %s', dn); | 190 module:log('debug', '_M.bind - who: %s', who); |
| 193 who = dn; | |
| 194 end | 191 end |
| 195 | 192 |
| 196 local conn, err = ldap.open_simple(params.hostname, who, password, params.use_tls); | 193 local conn, err = ldap.open_simple(params.hostname, who, password, params.use_tls); |
| 197 | 194 |
| 198 if conn then | 195 if conn then |
