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