It might be easier to understand if this happens before the loop.  e.g.:
```ruby
entries[0] = wldap32.ldap_first_entry(session_handle, search['res'])['return']
1.upto(max_search - 1) do |i|
  entries[i] = wldap32.ldap_next_entry(session_handle, entries[i-1])['return']
  ...
end
```