1 ! Copyright (C) 2007 Elie CHAFTARI
2 ! See http://factorcode.org/license.txt for BSD license.
4 ! Tested with OpenLDAP 2.2.7.0.21 on Mac OS X 10.4.9 PowerPC
6 ! export LD_LIBRARY_PATH=/opt/local/lib
8 USING: alien alien.syntax combinators kernel system ;
13 { [ win32? ] [ "libldap.dll" "stdcall" ] }
14 { [ macosx? ] [ "libldap.dylib" "cdecl" ] }
15 { [ unix? ] [ "libldap.so" "cdecl" ] }
18 : LDAP_VERSION1 1 ; inline
19 : LDAP_VERSION2 2 ; inline
20 : LDAP_VERSION3 3 ; inline
22 : LDAP_VERSION_MIN LDAP_VERSION2 ; inline
23 : LDAP_VERSION LDAP_VERSION2 ; inline
24 : LDAP_VERSION_MAX LDAP_VERSION3 ; inline
26 : LDAP_PORT 389 ; inline ! ldap:/// default LDAP port
27 : LDAPS_PORT 636 ; inline ! ldaps:/// default LDAP over TLS port
29 : LDAP_SCOPE_BASE HEX: 0000 ; inline
30 : LDAP_SCOPE_BASEOBJECT LDAP_SCOPE_BASE ; inline
31 : LDAP_SCOPE_ONELEVEL HEX: 0001 ; inline
32 : LDAP_SCOPE_ONE LDAP_SCOPE_ONELEVEL ; inline
33 : LDAP_SCOPE_SUBTREE HEX: 0002 ; inline
34 : LDAP_SCOPE_SUB LDAP_SCOPE_SUBTREE ; inline
35 : LDAP_SCOPE_SUBORDINATE HEX: 0003 ; inline ! OpenLDAP extension
36 : LDAP_SCOPE_CHILDREN LDAP_SCOPE_SUBORDINATE ; inline
37 : LDAP_SCOPE_DEFAULT -1 ; inline ! OpenLDAP extension
39 : LDAP_RES_ANY -1 ; inline
40 : LDAP_RES_UNSOLICITED 0 ; inline
42 ! how many messages to retrieve results for
43 : LDAP_MSG_ONE HEX: 00 ; inline
44 : LDAP_MSG_ALL HEX: 01 ; inline
45 : LDAP_MSG_RECEIVED HEX: 02 ; inline
47 ! the possible result types returned
48 : LDAP_RES_BIND HEX: 61 ; inline
49 : LDAP_RES_SEARCH_ENTRY HEX: 64 ; inline
50 : LDAP_RES_SEARCH_REFERENCE HEX: 73 ; inline
51 : LDAP_RES_SEARCH_RESULT HEX: 65 ; inline
52 : LDAP_RES_MODIFY HEX: 67 ; inline
53 : LDAP_RES_ADD HEX: 69 ; inline
54 : LDAP_RES_DELETE HEX: 6b ; inline
55 : LDAP_RES_MODDN HEX: 6d ; inline
56 : LDAP_RES_COMPARE HEX: 6f ; inline
57 : LDAP_RES_EXTENDED HEX: 78 ; inline
58 : LDAP_RES_EXTENDED_PARTIAL HEX: 79 ; inline
60 : result-types ( -- seq ) {
61 { HEX: 61 "LDAP_RES_BIND" }
62 { HEX: 64 "LDAP_RES_SEARCH_ENTRY" }
63 { HEX: 73 "LDAP_RES_SEARCH_REFERENCE" }
64 { HEX: 65 "LDAP_RES_SEARCH_RESULT" }
65 { HEX: 67 "LDAP_RES_MODIFY" }
66 { HEX: 69 "LDAP_RES_ADD" }
67 { HEX: 6b "LDAP_RES_DELETE" }
68 { HEX: 6d "LDAP_RES_MODDN" }
69 { HEX: 6f "LDAP_RES_COMPARE" }
70 { HEX: 78 "LDAP_RES_EXTENDED" }
71 { HEX: 79 "LDAP_RES_EXTENDED_PARTIAL" }
74 : LDAP_OPT_PROTOCOL_VERSION HEX: 0011 ; inline
77 { "char" "ld_lberoptions" }
79 { "int" "ld_timelimit" }
80 { "int" "ld_sizelimit" }
82 { "char*" "ld_error" }
83 { "char*" "ld_matched" }
84 { "int" "ld_refhoplimit" }
85 { "ulong" "ld_options" } ;
89 ! ===============================================
91 ! ===============================================
93 ! Will be depreciated in a later release (ldap_init() is preferred)
94 FUNCTION: void* ldap_open ( char* host, int port ) ;
96 FUNCTION: void* ldap_init ( char* host, int port ) ;
98 FUNCTION: int ldap_initialize ( ldap* ld, char* url ) ;
100 FUNCTION: int ldap_get_option ( void* ld, int option, void* outvalue ) ;
102 FUNCTION: int ldap_set_option ( void* ld, int option, void* invalue ) ;
104 FUNCTION: int ldap_simple_bind ( void* ld, char* who, char* passwd ) ;
106 FUNCTION: int ldap_simple_bind_s ( void* ld, char* who, char* passwd ) ;
108 FUNCTION: int ldap_unbind_s ( void* ld ) ;
110 FUNCTION: int ldap_result2error ( void* ld, void* res, int freeit ) ;
112 FUNCTION: char* ldap_err2string ( int err ) ;
114 FUNCTION: int ldap_search ( void* ld, char* base, int scope, char* filter,
115 char* attrs, int attrsonly ) ;
117 FUNCTION: int ldap_search_s ( void* ld, char* base, int scope, char* filter,
118 char* attrs, int attrsonly, void* res ) ;
120 FUNCTION: int ldap_result ( void* ld, int msgid, int all, void* timeout,
123 FUNCTION: int ldap_parse_result ( void* ld, void* result, int* errcodep,
124 char* matcheddnp, char* errmsgp,
125 char* referralsp, void* serverctrlsp,
128 FUNCTION: int ldap_count_messages ( void* ld, void* result ) ;
130 FUNCTION: void* ldap_first_message ( void* ld, void* result ) ;
132 FUNCTION: void* ldap_next_message ( void* ld, void* message ) ;
134 FUNCTION: int ldap_msgtype ( void* msg ) ;
136 FUNCTION: int ldap_msgid ( void* msg ) ;
138 FUNCTION: int ldap_count_entries ( void* ld, void* result ) ;
140 FUNCTION: void* ldap_first_entry ( void* ld, void* result ) ;
142 FUNCTION: void* ldap_next_entry ( void* ld, void* entry ) ;
144 FUNCTION: char* ldap_first_attribute ( void* ld, void* entry, void* berptr ) ;
146 FUNCTION: char* ldap_next_attribute ( void* ld, void* entry, void* ber ) ;
148 FUNCTION: char** ldap_get_values ( void* ld, void* entry, char* attr ) ;
150 FUNCTION: char* ldap_get_dn ( void* ld, void* entry ) ;