;;; ,open ldap-low ldap-types pp (define (open-anonymous-ldap-v3-session host) (let ((session (ldap-init host))) (set-ldap-session-option! (ldap-session-option-value protocol-version) 3 session) (ldap-simple-bind-as-nobody session) session)) (define (get-value-alist entry) (let ((attributes (ldap-all-attributes entry))) (map (lambda (attribute) (cons (string->symbol attribute) (ldap-get-values entry attribute))) attributes))) (define (find-all-entries host root-dn) (with-ldap-session (open-anonymous-ldap-v3-session host) (lambda () (let ((first-entry (ldap-search root-dn (ldap-scope-arguments onelevel) "(objectClass=*)" ldap-attributes-all-user-attributes #f))) (let lp ((entry (ldap-first-entry first-entry)) (res '())) (if (not entry) res (lp (ldap-next-entry entry) (cons (ldap-entry-dn entry) (cons (get-value-alist entry) res)))))))))