Add check around filter loops

Otherwise, "Can't use an undefined value as an ARRAY reference".
Use ldap obj as parameter instead of global
Add search scope
Refactor conn & bind to sub routine
Add support for binding