2004-02-13 12:04:30 -05:00
|
|
|
(define ddisplay
|
|
|
|
(lambda lst
|
|
|
|
(for-each
|
|
|
|
(lambda (x)
|
|
|
|
(cond
|
|
|
|
((ldap-message? x)
|
|
|
|
(display (number->string (ldap-message-c-pointer x) 16)))
|
|
|
|
((ber-element? x)
|
|
|
|
(display (number->string (ber-element-c-pointer x) 16)))
|
2004-02-14 10:37:55 -05:00
|
|
|
((ldap-session? x)
|
|
|
|
(display (number->string (ldap-session-c-pointer x) 16)))
|
2004-02-13 12:04:30 -05:00
|
|
|
(else
|
|
|
|
(display x))))
|
|
|
|
lst)
|
|
|
|
(newline)
|
|
|
|
(force-output (current-output-port))))
|
|
|
|
|
|
|
|
(define *object-table*
|
|
|
|
(make-value-weak-table))
|
2003-10-28 10:27:54 -05:00
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define $current-ldap-session (make-fluid #f))
|
|
|
|
|
|
|
|
(define (current-ldap-session)
|
|
|
|
(fluid $current-ldap-session))
|
|
|
|
|
|
|
|
(define (with-ldap-session session thunk)
|
|
|
|
(let-fluid $current-ldap-session session thunk))
|
|
|
|
|
2004-01-08 02:45:28 -05:00
|
|
|
(import-lambda-definition ldap-session-free
|
|
|
|
(session)
|
|
|
|
"scsh_ldap_memfree")
|
|
|
|
|
|
|
|
(define (ldap-session-finalizer session)
|
2004-02-14 10:37:55 -05:00
|
|
|
(ddisplay "FREE ldap-session " session)
|
2004-01-08 02:45:28 -05:00
|
|
|
(if (ldap-session-bound? session)
|
|
|
|
(if (not (ldap-session-implicit-unbind-ok? session))
|
2004-02-14 10:37:55 -05:00
|
|
|
(raise (condition
|
|
|
|
(&ldap-implicit-unbind (code #f) (session session))))
|
2004-01-08 02:45:28 -05:00
|
|
|
(if (ldap-session-auto-unbind? session)
|
2004-02-13 12:04:30 -05:00
|
|
|
(ldap-unbind session))))
|
|
|
|
(remove-from-weak-table! *object-table* (ldap-session-c-pointer session))
|
|
|
|
(ldap-session-free session))
|
2004-01-08 02:45:28 -05:00
|
|
|
|
|
|
|
(import-lambda-definition ldap-init-internal
|
|
|
|
(host port)
|
|
|
|
"scsh_ldap_init")
|
|
|
|
|
2004-02-11 11:16:03 -05:00
|
|
|
(define (ldap-init host-name-or-list . args)
|
2004-01-08 02:45:28 -05:00
|
|
|
(let-optionals args
|
2004-02-11 11:16:03 -05:00
|
|
|
((port 0) ; use default port
|
|
|
|
(implicit-unbind-ok? #f)
|
2004-01-08 02:45:28 -05:00
|
|
|
(unbind-automatically? #t))
|
2004-02-11 11:16:03 -05:00
|
|
|
(let ((hosts (if (list? host-name-or-list)
|
|
|
|
(string-join host-name-or-list)
|
|
|
|
host-name-or-list)))
|
|
|
|
(let ((session (ldap-init-internal hosts port))
|
|
|
|
(options (make-session-options implicit-unbind-ok?
|
|
|
|
unbind-automatically?)))
|
2004-02-13 12:04:30 -05:00
|
|
|
(add-to-weak-table! *object-table*
|
|
|
|
(ldap-session-c-pointer session)
|
|
|
|
session)
|
2004-02-11 11:16:03 -05:00
|
|
|
(add-finalizer! session ldap-session-finalizer)
|
|
|
|
(set-ldap-session-bound?! session #f)
|
|
|
|
(set-ldap-session-options! session options)
|
|
|
|
session))))
|
2004-01-08 02:45:28 -05:00
|
|
|
|
2004-01-15 11:34:15 -05:00
|
|
|
;;; SIMPLE_BIND_S
|
2004-01-08 02:45:28 -05:00
|
|
|
|
|
|
|
(import-lambda-definition ldap-simple-bind-internal
|
|
|
|
(session user cred)
|
|
|
|
"scsh_ldap_simple_bind_s")
|
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (ldap-simple-bind user password . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(let ((ret-obj
|
|
|
|
(convert-ldap-return-code
|
|
|
|
(ldap-simple-bind-internal session user password))))
|
|
|
|
(if (ldap-success? ret-obj)
|
|
|
|
(set-ldap-session-bound?! session #t)
|
|
|
|
(raise-ldap-condition ret-obj session)))))
|
2004-01-08 02:45:28 -05:00
|
|
|
|
2004-02-13 12:04:30 -05:00
|
|
|
(define (ldap-simple-bind-anonymous . args)
|
2004-02-13 05:06:15 -05:00
|
|
|
(let-optionals args ((session . (current-ldap-session)))
|
|
|
|
(ldap-simple-bind #f #f session)))
|
2004-02-11 11:16:03 -05:00
|
|
|
|
2004-01-15 11:34:15 -05:00
|
|
|
;;; SASL_BIND_S
|
2004-01-08 02:45:28 -05:00
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
;;; FIXME: Need interface to BER-elements before this functions is
|
|
|
|
;;; usable
|
|
|
|
|
2004-01-08 02:45:28 -05:00
|
|
|
(import-lambda-definition ldap-sasl-bind-internal
|
|
|
|
(session dn mechanism cred server-controls client-controls server-cred)
|
|
|
|
"scsh_ldap_sasl_bind_s")
|
|
|
|
|
|
|
|
(define (ldap-sasl-bind session dn mechanism cred
|
|
|
|
server-controls client-controls
|
|
|
|
credentials)
|
2004-02-10 10:28:34 -05:00
|
|
|
(raise (condition (&ldap-bindings-not-implemented
|
2004-02-14 10:37:55 -05:00
|
|
|
(what '(ldap-sasl-bind ldap-controls))
|
|
|
|
(session #f) (code #f)))))
|
2004-01-08 02:45:28 -05:00
|
|
|
|
2004-01-15 11:34:15 -05:00
|
|
|
;;; UNBIND_S
|
2004-01-08 02:45:28 -05:00
|
|
|
|
|
|
|
(import-lambda-definition ldap-unbind-internal
|
|
|
|
(session)
|
|
|
|
"scsh_ldap_unbind_s")
|
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (ldap-unbind . args)
|
|
|
|
(let-optionals args ((session . (current-ldap-session)))
|
|
|
|
(let ((ret-obj
|
|
|
|
(convert-ldap-return-code (ldap-unbind-internal session))))
|
|
|
|
(if (ldap-success? ret-obj)
|
|
|
|
(set-ldap-session-bound?! session #f)
|
|
|
|
(raise-ldap-condition ret-obj session)))))
|
2004-01-08 02:45:28 -05:00
|
|
|
|
2004-01-15 11:34:15 -05:00
|
|
|
;;; SEARCH_S and SEARCH_ST
|
2004-01-08 02:45:28 -05:00
|
|
|
|
|
|
|
(import-lambda-definition ldap-search-internal
|
|
|
|
(session base scope filter attribute-list attributes-only?)
|
|
|
|
"scsh_ldap_search_s")
|
|
|
|
|
|
|
|
(import-lambda-definition ldap-search-with-timeout-internal
|
|
|
|
(session base scope filter attribute-list attributes-only? timeout-sec timeout-usec)
|
|
|
|
"scsh_ldap_search_st")
|
|
|
|
|
2004-02-13 12:04:30 -05:00
|
|
|
(import-lambda-definition ldap-msgfree
|
2004-01-08 02:45:28 -05:00
|
|
|
(message)
|
|
|
|
"scsh_ldap_msgfree")
|
|
|
|
|
2004-02-13 12:04:30 -05:00
|
|
|
(define (ldap-message-unregister-object message)
|
2004-02-14 10:37:55 -05:00
|
|
|
(ddisplay "UNREGISTER ldap-message " message)
|
2004-02-13 12:04:30 -05:00
|
|
|
(remove-from-weak-table! *object-table*
|
|
|
|
(ldap-message-c-pointer message)))
|
|
|
|
|
|
|
|
(define (ldap-message-freeing-finalizer message)
|
2004-02-14 10:37:55 -05:00
|
|
|
(ddisplay "FREE ldap-message " message)
|
2004-02-13 12:04:30 -05:00
|
|
|
(ldap-message-unregister-object message)
|
|
|
|
(ldap-msgfree message))
|
2004-01-08 02:45:28 -05:00
|
|
|
|
|
|
|
(define (ldap-attribute-list-kludge attribute-list)
|
|
|
|
(cond ((eq? attribute-list ldap-attributes-no-attribute)
|
|
|
|
(list ldap-attributes-no-attribute))
|
|
|
|
((eq? attribute-list ldap-attributes-all-user-attributes)
|
|
|
|
(list ldap-attributes-all-user-attributes))
|
|
|
|
(else attribute-list)))
|
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (ldap-search base scope filter attribute-list attributes-only? . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session))
|
|
|
|
(timeout-seconds #f)
|
|
|
|
(timeout-microseconds #f))
|
2004-02-10 10:28:34 -05:00
|
|
|
(let ((scope-id (ldap-scope-arguments-id scope))
|
2004-01-08 02:45:28 -05:00
|
|
|
(attr-list (ldap-attribute-list-kludge attribute-list)))
|
|
|
|
(call-with-values
|
|
|
|
(lambda ()
|
|
|
|
(apply values
|
|
|
|
(if (not timeout-seconds)
|
|
|
|
(ldap-search-internal
|
2004-02-12 07:44:46 -05:00
|
|
|
session base scope-id filter attr-list attributes-only?)
|
2004-01-08 02:45:28 -05:00
|
|
|
(ldap-search-with-timeout-internal
|
2004-02-12 07:44:46 -05:00
|
|
|
session base scope-id filter attr-list attributes-only?
|
2004-01-08 02:45:28 -05:00
|
|
|
timeout-seconds (or timeout-microseconds 0)))))
|
|
|
|
(lambda (ret-code message)
|
2004-02-10 10:28:34 -05:00
|
|
|
(let ((ret-obj
|
|
|
|
(convert-ldap-return-code ret-code)))
|
2004-01-08 02:45:28 -05:00
|
|
|
(if (ldap-success? ret-obj)
|
2004-02-13 12:04:30 -05:00
|
|
|
(let ((pointer (ldap-message-c-pointer message)))
|
|
|
|
(ddisplay "ldap-search")
|
|
|
|
(or (lookup-in-weak-table *object-table* pointer)
|
|
|
|
(begin
|
|
|
|
(ddisplay "ldap-search new object " message)
|
|
|
|
(add-to-weak-table! *object-table* pointer message)
|
|
|
|
(set-ldap-message-session! message session)
|
2004-02-14 10:37:55 -05:00
|
|
|
(set-ldap-message-result! message #f)
|
2004-02-13 12:04:30 -05:00
|
|
|
(add-finalizer! message ldap-message-freeing-finalizer)
|
|
|
|
message)))
|
2004-02-10 10:28:34 -05:00
|
|
|
(raise-ldap-condition ret-obj session))))))))
|
2004-01-08 02:45:28 -05:00
|
|
|
|
2004-01-15 11:34:15 -05:00
|
|
|
;;; GET/SET session options
|
2004-01-08 02:45:28 -05:00
|
|
|
|
|
|
|
(import-lambda-definition ldap-get-set-option-internal
|
|
|
|
(session option set? value)
|
|
|
|
"scsh_ldap_get_set_option")
|
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (set-ldap-session-option! session-option value . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(call-with-values
|
|
|
|
(lambda ()
|
|
|
|
(apply values
|
|
|
|
(ldap-get-set-option-internal
|
|
|
|
session (ldap-session-option-value-id session-option) #t value)))
|
|
|
|
(lambda (call-successful? result)
|
|
|
|
(if call-successful?
|
|
|
|
result
|
|
|
|
(raise
|
2004-02-14 10:37:55 -05:00
|
|
|
(condition (&ldap-session-option-error
|
|
|
|
(code #f) (session session)))))))))
|
2004-02-13 05:06:15 -05:00
|
|
|
|
|
|
|
(define (ldap-session-option session-option . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(call-with-values
|
|
|
|
(lambda ()
|
|
|
|
(apply values
|
|
|
|
(ldap-get-set-option-internal
|
|
|
|
session (ldap-session-option-value-id session-option) #f #f)))
|
|
|
|
(lambda (call-successful? result)
|
|
|
|
(if call-successful?
|
|
|
|
result
|
|
|
|
(raise
|
2004-02-14 10:37:55 -05:00
|
|
|
(condition (&ldap-session-option-error
|
|
|
|
(code #f) (session session)))))))))
|
2004-01-08 02:45:28 -05:00
|
|
|
|
2004-01-15 11:34:15 -05:00
|
|
|
;;;
|
2004-01-08 02:45:28 -05:00
|
|
|
|
|
|
|
(import-lambda-definition ldap-error-string-internal
|
|
|
|
(session error-code)
|
|
|
|
"scsh_ldap_error_string")
|
|
|
|
|
|
|
|
(define (ldap-get-error-return-object session)
|
2004-02-12 07:44:46 -05:00
|
|
|
(convert-ldap-return-code
|
2004-02-13 05:06:15 -05:00
|
|
|
(ldap-session-option (ldap-session-option-value error-number) session)))
|
2004-01-08 02:45:28 -05:00
|
|
|
|
2004-01-15 11:34:15 -05:00
|
|
|
;;; FIRST/NEXT_MESSAGE, COUNT_MESSAGES
|
2004-01-08 02:45:28 -05:00
|
|
|
|
|
|
|
(import-lambda-definition ldap-first-message-internal
|
|
|
|
(session message)
|
|
|
|
"scsh_ldap_first_message")
|
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (ldap-first-message message . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
2004-02-13 12:04:30 -05:00
|
|
|
(cond
|
|
|
|
((ldap-first-message-internal session message)
|
|
|
|
=> (lambda (new-message)
|
|
|
|
(let ((pointer (ldap-message-c-pointer new-message)))
|
|
|
|
(or (lookup-in-weak-table *object-table* pointer)
|
|
|
|
(begin
|
|
|
|
(add-to-weak-table! *object-table* pointer new-message)
|
|
|
|
(set-ldap-message-session! new-message session)
|
|
|
|
(add-finalizer! new-message ldap-message-freeing-finalizer)
|
|
|
|
new-message)))))
|
|
|
|
(else
|
|
|
|
(raise-ldap-condition
|
|
|
|
(ldap-get-error-return-object session) session)))))
|
2004-01-08 02:45:28 -05:00
|
|
|
|
|
|
|
(import-lambda-definition ldap-next-message-internal
|
|
|
|
(session message)
|
|
|
|
"scsh_ldap_next_message")
|
|
|
|
|
2004-02-13 12:04:30 -05:00
|
|
|
(define (ldap-next-message message . args)
|
2004-02-13 05:06:15 -05:00
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
2004-02-13 12:04:30 -05:00
|
|
|
(cond
|
|
|
|
((ldap-next-message-internal session message)
|
|
|
|
=> (lambda (new-message)
|
|
|
|
(let ((pointer (ldap-message-c-pointer new-message)))
|
|
|
|
(or (lookup-in-weak-table *object-table* pointer)
|
|
|
|
(begin
|
|
|
|
(add-to-weak-table! *object-table* pointer new-message)
|
|
|
|
(set-ldap-message-session! new-message session)
|
|
|
|
(add-finalizer! new-message ldap-message-freeing-finalizer)
|
|
|
|
new-message)))))
|
|
|
|
(else
|
|
|
|
(raise-ldap-condition
|
|
|
|
(ldap-get-error-return-object session) session)))))
|
2004-01-08 02:45:28 -05:00
|
|
|
|
|
|
|
(import-lambda-definition ldap-count-messages-internal
|
|
|
|
(session message)
|
|
|
|
"scsh_ldap_count_messages")
|
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (ldap-count-messages message . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(let ((ret (ldap-count-messages-internal session message)))
|
|
|
|
(or ret
|
|
|
|
(raise-ldap-condition (ldap-get-error-return-object session) session)))))
|
2004-01-15 11:34:15 -05:00
|
|
|
|
|
|
|
;;;
|
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
;;; FIXME: Do we need this function if we introduce types for the
|
|
|
|
;;; diffrent ldap-messages?
|
|
|
|
|
2004-01-15 11:34:15 -05:00
|
|
|
(import-lambda-definition ldap-get-message-type-internal
|
|
|
|
(message)
|
|
|
|
"scsh_ldap_msgtype")
|
|
|
|
|
2004-02-13 12:04:30 -05:00
|
|
|
(define (ldap-message-type session message)
|
2004-01-15 11:34:15 -05:00
|
|
|
(cond
|
|
|
|
((ldap-get-message-type-internal message)
|
2004-02-10 10:28:34 -05:00
|
|
|
=> (lambda (code) (convert-ldap-message-type code)))
|
2004-01-15 11:34:15 -05:00
|
|
|
(else
|
2004-02-10 10:28:34 -05:00
|
|
|
(raise-ldap-condition (ldap-get-error-return-object session) session))))
|
2004-01-15 11:34:15 -05:00
|
|
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
(import-lambda-definition ldap-message-id-internal
|
|
|
|
(message)
|
|
|
|
"scsh_ldap_msgid")
|
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (ldap-get-message-id message . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(or (ldap-message-id-internal message)
|
|
|
|
(raise-ldap-condition (ldap-get-error-return-object session) session))))
|
2004-01-15 11:34:15 -05:00
|
|
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
(import-lambda-definition ldap-first-attribute-internal
|
|
|
|
(session entry)
|
|
|
|
"scsh_ldap_first_attribute")
|
|
|
|
|
|
|
|
(import-lambda-definition ldap-next-attribute-internal
|
|
|
|
(session entry ber-element)
|
|
|
|
"scsh_ldap_next_attribute")
|
|
|
|
|
|
|
|
(import-lambda-definition ber-element-free
|
|
|
|
(ber-element fbuf)
|
|
|
|
"scsh_ldap_ber_free")
|
|
|
|
|
|
|
|
(define (ber-element-finalizer ber-element)
|
2004-02-14 10:37:55 -05:00
|
|
|
(ddisplay "FREE ber-element " ber-element)
|
2004-02-13 12:04:30 -05:00
|
|
|
(remove-from-weak-table!
|
|
|
|
*object-table* (ber-element-c-pointer ber-element))
|
2004-01-15 11:34:15 -05:00
|
|
|
(ber-element-free ber-element 1))
|
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (ldap-first-attribute entry . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(call-with-values
|
|
|
|
(lambda ()
|
|
|
|
(apply values
|
2004-02-13 12:04:30 -05:00
|
|
|
(ldap-first-attribute-internal session entry)))
|
2004-02-13 05:06:15 -05:00
|
|
|
(lambda (attribute-name ber-element)
|
|
|
|
(if attribute-name
|
2004-02-13 12:04:30 -05:00
|
|
|
(cond
|
|
|
|
((lookup-in-weak-table *object-table*
|
|
|
|
(ber-element-c-pointer ber-element))
|
|
|
|
=> (lambda (be)
|
2004-02-14 10:37:55 -05:00
|
|
|
(ddisplay "RE ber-element (ldap-first-attribute) " be)
|
2004-02-13 12:04:30 -05:00
|
|
|
(values attribute-name be)))
|
|
|
|
(else
|
2004-02-14 10:37:55 -05:00
|
|
|
(ddisplay "NEW ber-element (ldap-first-attribute) " ber-element)
|
2004-02-13 05:06:15 -05:00
|
|
|
(add-finalizer! ber-element ber-element-finalizer)
|
2004-02-13 12:04:30 -05:00
|
|
|
(values attribute-name ber-element)))
|
|
|
|
(raise-ldap-condition
|
|
|
|
(ldap-get-error-return-object session) session))))))
|
2004-02-13 05:06:15 -05:00
|
|
|
|
|
|
|
(define (ldap-next-attribute entry ber-element . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
2004-02-13 12:04:30 -05:00
|
|
|
(or (ldap-next-attribute-internal session entry ber-element)
|
2004-02-13 05:06:15 -05:00
|
|
|
(let ((ret-obj (ldap-get-error-return-object session)))
|
|
|
|
(if (ldap-success? ret-obj)
|
|
|
|
#f
|
|
|
|
(raise-ldap-condition ret-obj session))))))
|
|
|
|
|
|
|
|
(define (ldap-all-attributes entry . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(call-with-values
|
|
|
|
(lambda ()
|
|
|
|
(ldap-first-attribute entry session))
|
|
|
|
(lambda (first-attribute ber-element)
|
|
|
|
(let loop ((next (ldap-next-attribute entry ber-element session))
|
|
|
|
(attributes (list first-attribute)))
|
|
|
|
(if next
|
|
|
|
(loop (ldap-next-attribute entry ber-element session)
|
|
|
|
(cons next attributes))
|
|
|
|
attributes))))))
|
2004-01-15 11:34:15 -05:00
|
|
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
(import-lambda-definition ldap-get-values-internal
|
|
|
|
(session entry attribute)
|
|
|
|
"scsh_ldap_get_values")
|
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (ldap-get-values entry attribute-name . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(let ((val (ldap-get-values-internal
|
2004-02-13 12:04:30 -05:00
|
|
|
session entry attribute-name)))
|
2004-02-13 05:06:15 -05:00
|
|
|
(or val
|
|
|
|
(let ((ret-obj (ldap-get-error-return-object session)))
|
|
|
|
(if (ldap-success? ret-obj)
|
|
|
|
val
|
|
|
|
(raise-ldap-condition ret-obj session)))))))
|
2004-01-08 02:45:28 -05:00
|
|
|
|
|
|
|
;;;
|
|
|
|
|
2004-02-13 12:04:30 -05:00
|
|
|
(import-lambda-definition ldap-compare-internal
|
2004-01-08 02:45:28 -05:00
|
|
|
(session dn attribute value)
|
|
|
|
"scsh_ldap_compare_s")
|
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (ldap-compare dn attribute value . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(let ((ret-obj
|
|
|
|
(convert-ldap-return-code
|
|
|
|
(ldap-compare-internal session dn attribute value))))
|
|
|
|
(if (or (equal? (ldap-return compare-true) ret-obj)
|
|
|
|
(equal? (ldap-return compare-false) ret-obj))
|
|
|
|
(equal? (ldap-return compare-true) ret-obj)
|
|
|
|
(raise-ldap-condition ret-obj session)))))
|
2004-01-08 02:45:28 -05:00
|
|
|
|
2004-01-15 11:34:15 -05:00
|
|
|
;;;
|
2004-01-08 02:45:28 -05:00
|
|
|
|
|
|
|
(import-lambda-definition ldap-get-dn-internal
|
|
|
|
(session message)
|
|
|
|
"scsh_ldap_get_dn")
|
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (ldap-entry-dn entry . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
2004-02-13 12:04:30 -05:00
|
|
|
(or (ldap-get-dn-internal session entry)
|
2004-02-13 05:06:15 -05:00
|
|
|
(raise-ldap-condition
|
|
|
|
(ldap-get-error-return-object session) session))))
|
2004-01-15 11:34:15 -05:00
|
|
|
|
|
|
|
;;;
|
|
|
|
|
2004-01-08 02:45:28 -05:00
|
|
|
(import-lambda-definition ldap-explode-dn-internal
|
|
|
|
(dn no-types?)
|
|
|
|
"scsh_ldap_explode_dn")
|
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (ldap-explode-dn dn no-types? . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(or (ldap-explode-dn-internal dn no-types?)
|
|
|
|
(raise-ldap-condition
|
|
|
|
(ldap-get-error-return-object session) session))))
|
2004-01-15 11:34:15 -05:00
|
|
|
|
|
|
|
;;;
|
|
|
|
|
2004-01-08 02:45:28 -05:00
|
|
|
(import-lambda-definition ldap-explode-rdn-internal
|
|
|
|
(dn no-types?)
|
|
|
|
"scsh_ldap_explode_rdn")
|
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (ldap-explode-rdn dn no-types? . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(or (ldap-explode-rdn-internal dn no-types?)
|
|
|
|
(raise-ldap-condition
|
|
|
|
(ldap-get-error-return-object session dn no-types?)))))
|
2004-01-15 11:34:15 -05:00
|
|
|
|
|
|
|
;;;
|
|
|
|
|
2004-01-08 02:45:28 -05:00
|
|
|
(import-lambda-definition ldap-dn2ufn-internal
|
|
|
|
(dn)
|
|
|
|
"scsh_ldap_dn2ufn")
|
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (ldap-make-dn-userfriendly dn . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(or (ldap-dn2ufn-internal dn)
|
|
|
|
(raise-ldap-condition
|
|
|
|
(ldap-get-error-return-object session) session))))
|
2004-01-15 11:34:15 -05:00
|
|
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
(import-lambda-definition ldap-count-entries-internal
|
|
|
|
(session message)
|
|
|
|
"scsh_ldap_count_entries")
|
|
|
|
|
|
|
|
(import-lambda-definition ldap-first-entry-internal
|
|
|
|
(session message)
|
|
|
|
"scsh_ldap_first_entry")
|
|
|
|
|
|
|
|
(import-lambda-definition ldap-next-entry-internal
|
|
|
|
(session message)
|
|
|
|
"scsh_ldap_next_entry")
|
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (ldap-count-entries entry . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
2004-02-13 12:04:30 -05:00
|
|
|
(or (ldap-count-entries-internal session entry)
|
2004-02-13 05:06:15 -05:00
|
|
|
(raise-ldap-condition
|
|
|
|
(ldap-get-error-return-object session) session))))
|
|
|
|
|
2004-02-13 12:04:30 -05:00
|
|
|
(define (ldap-first-entry result . args)
|
2004-02-13 05:06:15 -05:00
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(cond
|
2004-02-13 12:04:30 -05:00
|
|
|
((ldap-first-entry-internal session result)
|
2004-02-13 05:06:15 -05:00
|
|
|
=> (lambda (new-message)
|
2004-02-13 12:04:30 -05:00
|
|
|
(let ((pointer (ldap-message-c-pointer new-message)))
|
2004-02-14 10:37:55 -05:00
|
|
|
(cond
|
|
|
|
((lookup-in-weak-table *object-table* pointer)
|
|
|
|
=> (lambda (old-object)
|
|
|
|
(ddisplay "REUSE ldap-message as entry " old-object)
|
|
|
|
;; nomitated in the category "hack of the year"
|
|
|
|
(set-ldap-message-result! old-object old-object)
|
|
|
|
old-object))
|
|
|
|
(else
|
|
|
|
;; it's not certain that this code will ever be reached.
|
|
|
|
;;
|
|
|
|
;; don't add a finalizer in this case, because
|
|
|
|
;; libldap will free the memory itself.
|
|
|
|
(ddisplay "NEW object (ldap-first-entry) result "
|
|
|
|
result " new-message " new-message)
|
|
|
|
(add-to-weak-table! *object-table* pointer new-message)
|
|
|
|
(set-ldap-message-session! new-message session)
|
|
|
|
(set-ldap-message-result! new-message result)
|
|
|
|
(add-finalizer! new-message ldap-message-unregister-object)
|
|
|
|
new-message))))
|
|
|
|
(else
|
|
|
|
(let ((ret-obj (ldap-get-error-return-object session)))
|
|
|
|
(if (ldap-success? ret-obj)
|
|
|
|
#f
|
|
|
|
(raise-ldap-condition ret-obj session))))))))
|
2004-02-13 05:06:15 -05:00
|
|
|
|
|
|
|
(define (ldap-next-entry entry . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(cond
|
2004-02-13 12:04:30 -05:00
|
|
|
((ldap-next-entry-internal session entry)
|
2004-02-13 05:06:15 -05:00
|
|
|
=> (lambda (new-message)
|
2004-02-13 12:04:30 -05:00
|
|
|
(let ((pointer (ldap-message-c-pointer new-message)))
|
|
|
|
(or (lookup-in-weak-table *object-table* pointer)
|
|
|
|
(begin
|
2004-02-14 10:37:55 -05:00
|
|
|
(ddisplay "NEW message (ldap-next-entry) " new-message
|
|
|
|
" parent " (ldap-message-result entry))
|
2004-02-13 12:04:30 -05:00
|
|
|
;; don't add a finalizer in this case, because
|
|
|
|
;; libldap will free the memory itself.
|
|
|
|
(add-to-weak-table! *object-table* pointer new-message)
|
|
|
|
(set-ldap-message-session! new-message session)
|
2004-02-14 10:37:55 -05:00
|
|
|
(set-ldap-message-result! new-message (ldap-message-result entry))
|
2004-02-13 12:04:30 -05:00
|
|
|
(add-finalizer! new-message ldap-message-unregister-object)
|
|
|
|
new-message)))))
|
2004-02-13 05:06:15 -05:00
|
|
|
(else
|
2004-02-13 12:04:30 -05:00
|
|
|
(let ((ret-obj (ldap-get-error-return-object session)))
|
|
|
|
(if (ldap-success? ret-obj)
|
|
|
|
#f
|
|
|
|
(raise-ldap-condition ret-obj session)))))))
|
2004-01-15 11:34:15 -05:00
|
|
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
(import-lambda-definition ldap-count-references-internal
|
|
|
|
(session message)
|
|
|
|
"scsh_ldap_count_references")
|
|
|
|
|
|
|
|
(import-lambda-definition ldap-first-reference-internal
|
|
|
|
(session message)
|
|
|
|
"scsh_ldap_first_reference")
|
|
|
|
|
|
|
|
(import-lambda-definition ldap-next-reference-internal
|
|
|
|
(session message)
|
|
|
|
"scsh_ldap_next_reference")
|
|
|
|
|
2004-02-13 12:04:30 -05:00
|
|
|
;;; FIXME: maybe add type, memory handling
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (ldap-count-references message . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(or (ldap-count-references-internal session message)
|
|
|
|
(raise-ldap-condition (ldap-get-error-return-object session) session))))
|
2004-01-15 11:34:15 -05:00
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (ldap-first-reference message . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(cond
|
|
|
|
((ldap-first-reference-internal session message)
|
|
|
|
=> (lambda (new-message)
|
2004-02-13 12:04:30 -05:00
|
|
|
(add-finalizer! new-message ldap-message-freeing-finalizer)
|
2004-02-13 05:06:15 -05:00
|
|
|
new-message))
|
|
|
|
(else
|
|
|
|
(let ((ret-obj (ldap-get-error-return-object session)))
|
|
|
|
(if (ldap-success? ret-obj)
|
|
|
|
#f
|
|
|
|
(raise-ldap-condition ret-obj session)))))))
|
|
|
|
|
|
|
|
(define (ldap-next-reference message . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(cond
|
|
|
|
((ldap-next-reference-internal session message)
|
|
|
|
=> (lambda (new-message)
|
2004-02-13 12:04:30 -05:00
|
|
|
(add-finalizer! new-message ldap-message-freeing-finalizer)
|
2004-02-13 05:06:15 -05:00
|
|
|
new-message))
|
|
|
|
(else
|
|
|
|
(let ((ret-obj (ldap-get-error-return-object session)))
|
|
|
|
(if (ldap-success? ret-obj)
|
|
|
|
#f
|
|
|
|
(raise-ldap-condition ret-obj session)))))))
|
2004-01-15 11:34:15 -05:00
|
|
|
|
|
|
|
;;;
|
2004-01-08 02:45:28 -05:00
|
|
|
|
|
|
|
(import-lambda-definition ldap-modify-internal
|
|
|
|
(session dn ldap-modification-vector)
|
|
|
|
"scsh_ldap_modify")
|
|
|
|
|
2004-02-13 05:06:15 -05:00
|
|
|
(define (ldap-modify dn ldap-modifications . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
2004-02-16 03:33:13 -05:00
|
|
|
(let ((ret-obj
|
|
|
|
(convert-ldap-return-code
|
|
|
|
(ldap-modify-internal session dn ldap-modifications))))
|
|
|
|
(or (ldap-success? ret-obj)
|
|
|
|
(raise-ldap-condition ret-obj session)))))
|
2004-02-10 10:28:34 -05:00
|
|
|
|
|
|
|
;;;
|
|
|
|
|
2004-01-08 02:45:28 -05:00
|
|
|
(import-lambda-definition ldap-add-internal
|
2004-02-16 03:33:13 -05:00
|
|
|
(session dn ldap-modifications)
|
2004-01-08 02:45:28 -05:00
|
|
|
"scsh_ldap_add")
|
|
|
|
|
2004-02-16 03:33:13 -05:00
|
|
|
(define (ldap-add dn ldap-modifications . args)
|
|
|
|
(let-optionals args ((session (current-ldap-session)))
|
|
|
|
(let ((ret-obj
|
|
|
|
(convert-ldap-return-code
|
|
|
|
(ldap-add-internal session dn ldap-modifications))))
|
|
|
|
(or (ldap-success? ret-obj)
|
|
|
|
(raise-ldap-condition ret-obj session)))))
|
|
|
|
|
2004-01-08 02:45:28 -05:00
|
|
|
(import-lambda-definition ldap-delete-internal
|
|
|
|
(session dn)
|
|
|
|
"scsh_ldap_delete")
|
|
|
|
|
|
|
|
(import-lambda-definition ldap-abandon-internal
|
|
|
|
(session message-id)
|
|
|
|
"scsh_ldap_abandon")
|