File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -253,13 +253,27 @@ def do_GET(self):
253
253
searchfilter, [' objectclass' ], 1)
254
254
255
255
ctx[' action' ] = ' verifying search query results'
256
- if len(results) < 1:
256
+
257
+ nres = len(results)
258
+
259
+ if nres < 1:
257
260
self.auth_failed(ctx, ' no objects found' )
258
261
return
259
262
260
- ctx[' action' ] = ' binding as an existing user'
261
- ldap_dn = results[0][0]
262
- ctx[' action' ] += ' "%s"' % ldap_dn
263
+ if nres > 1:
264
+ self.log_message(" note: filter match multiple objects: %d, using first" % nres)
265
+
266
+ user_entry = results[0]
267
+ ldap_dn = user_entry[0]
268
+
269
+ if ldap_dn == None:
270
+ self.auth_failed(ctx, ' matched object has no dn' )
271
+ return
272
+
273
+ self.log_message(' attempting to bind using dn "%s"' % (ldap_dn))
274
+
275
+ ctx[' action' ] = ' binding as an existing user "%s"' % ldap_dn
276
+
263
277
ldap_obj.bind_s(ldap_dn, ctx[' pass' ], ldap.AUTH_SIMPLE)
264
278
265
279
self.log_message(' Auth OK for user "%s"' % (ctx[' user' ]))
You can’t perform that action at this time.
0 commit comments