Mercurial > prosody-modules
comparison mod_lib_ldap/ldap.lib.lua @ 864:16b007c7706c
We must search for dn before trying to bind
| author | Guilhem LETTRON <guilhem.lettron@gmail.com> |
|---|---|
| date | Mon, 10 Dec 2012 21:52:09 +0100 |
| parents | 1d51c5e38faa |
| children | 0017518c94a0 |
comparison
equal
deleted
inserted
replaced
| 862:675945ea2ed6 | 864:16b007c7706c |
|---|---|
| 175 return params; | 175 return params; |
| 176 end | 176 end |
| 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 who = format('%s=%s,%s', params.user.usernamefield, username, params.user.basedn); | 180 local conn = _M.getconnection(); |
| 181 local filter = format('%s=%s', params.user.usernamefield, username); | |
| 182 local search_attrs = { | |
| 183 attrs = params.user.usernamefield, | |
| 184 base = params.user.basedn, | |
| 185 scope = 'subtree', | |
| 186 sizelimit = 1, | |
| 187 filter = filter, | |
| 188 }; | |
| 189 local who; | |
| 190 | |
| 191 for dn in conn:search(search_attrs) do | |
| 192 module:log('debug', '_M.bind - who: %s', dn); | |
| 193 who = dn; | |
| 194 end | |
| 195 | |
| 181 local conn, err = ldap.open_simple(params.hostname, who, password, params.use_tls); | 196 local conn, err = ldap.open_simple(params.hostname, who, password, params.use_tls); |
| 182 | 197 |
| 183 if conn then | 198 if conn then |
| 184 conn:close(); | 199 conn:close(); |
| 185 return true; | 200 return true; |
