File: README.LDAP

package info (click to toggle)
libtcl-ldap 1.0-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 180 kB
  • ctags: 305
  • sloc: ansic: 1,435; tcl: 161; makefile: 57
file content (241 lines) | stat: -rw-r--r-- 9,652 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
You will need the following files to compile the program:
 libldap.a (At least ldap v3.2)
 liblber.a (At least ldap v3.2)
 ldap.h
 lber.h
 ldapconfig.h
 TCL8.0 (TK8.0 optional)

All files (except tclAppInit.c) go in the "generic" directory.
The tclAppInit.c file goes in your platform-specific directory.
(i.e. unix, win, mac, vax, etc., etc., ad nauseum.)

You will need to make the following changes to the Makefile
in your platform-specific Makefile (or equivalent):

LIBS: (add)
 -lldap -llber

GENERIC_OBJS: (add)
tclLdapBind.o tclLdapDel.o tclLdapModRDN.o tclLdapSearch.o \
tclLdapUnBind.o tclLdapModify.o

GENERIC_SRCS: (add)
        $(GENERIC_DIR)/tclLdapBind.c \
        $(GENERIC_DIR)/tclLdapUnBind.c \
        $(GENERIC_DIR)/tclLdapDel.c \
        $(GENERIC_DIR)/tclLdapModRDN.c \
        $(GENERIC_DIR)/tclLdapSearch.c \
        $(GENERIC_DIR)/tclLdapModify.c \

# Object files used on all Unix systems: (add)
tclLdapBind.o: $(GENERIC_DIR)/tclLdapBind.c
        $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclLdapBind.c -llber -lldap

tclLdapUnBind.o: $(GENERIC_DIR)/tclLdapUnBind.c
        $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclLdapUnBind.c -llber -lldap

tclLdapDel.o: $(GENERIC_DIR)/tclLdapDel.c
        $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclLdapDel.c -llber -lldap

tclLdapModRDN.o: $(GENERIC_DIR)/tclLdapModRDN.c
        $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclLdapModRDN.c -llber -lldap

tclLdapSearch.o: $(GENERIC_DIR)/tclLdapSearch.c
        $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclLdapSearch.c -llber -lldap

tclLdapModify.o: $(GENERIC_DIR)/tclLdapModify.c
        $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclLdapModify.c -llber -lldap

ALSO! ADD the LIBS to the tk8.0 Makefile if you want these functions in your
wish programs!!!

then, all you should have to do is re-compile the tclsh binary and then
re-compile the wish binary (you only need to re-compile the wish binary if
you want to have these functions available in tk).


FUNCTIONS PROVIDED:
The code that I ported into tcl/tk is actually the tools code built by the
University of Michigan stripped down and squashed into a standard tcl
function.  Some of the functionality in the tool code has been removed in
oder to simplify the conversion process.  (Also, things like sorting a search
really aren't necessary since I return the results as a list. (You can use
lsort to sort the results))

I will be putting the source code onto the TCL archives. 

The LdapBind command currently supports a maximum of 1024 simultaneous
connections to various LDAP servers.  This limitation is controlled by
an array called "ldprime".  The current number of connections is stored
in a variable called "ldcnt".  Both of these variables are global to all
of the LDAP tcl functions.  To change the maximum connections you must
change the array value of ldprime in ALL of the source files.  You must
also change the tclLdapBind.c file line "if (ldcnt > 1023) {" to reflect
your new maximum (minus 1).  WARNING! There is currently NO means of
reclaiming freed connection slots.  (It should be simple to do, I just
haven't gotten around to it yet.)  But with over 1000 connections to use
before you have to re-start the tclsh, it should be sufficient for most
needs.

/******************************************************************************/
Command:   LdapBind
Arguments: Host Port BindDN Password
Where:     Host = Hostname or IP address of the LDAP server
           Port = IP port the LDAP server is listening on (ex: 389)
         BindDN = Manager's (or whoever's) DN
       Password = Password for the BindDN
Results:
      data: Returns an integer number identifying the established connection.
    errors: Too many connections!
            Cannot connect to host
            Invalid name or password
  messages: None
Return codes:
  success: TCL_OK
  failure: TCL_ERROR
Note: Each argument to the LdapBind command can be a variable.
      Multiple connections can be established to the same or different hosts.
      Each LdapBind call will return a unique number associated with the
      connection that identifies the connection to the other Ldap commands.
Example:
set connection [LdapBind host1 389 "cn=mgr,o=org1,c=us" "mgrpwd"]
or
set connection [LdapBind $host $port $mgr $mgrpwd]
/******************************************************************************/

/******************************************************************************/
Command:   LdapUnBind
Arguments: ConnID
Where:   ConnID = Connection number returned from previous LdapBind
Results:
      data: None
    errors: Invalid connection number!
  messages: None
Return codes:
  success: TCL_OK
  failure: TCL_ERROR
Note: Each argument to the LdapUnBind command can be a variable.
      This command will close a connection made with a previous LdapBind.
Example:
LdapUnBind 0
or
LdapUnBind $connection
/******************************************************************************/

/******************************************************************************/
Command:   LdapDelete
Arguments: ConnectionID DN-to-delete
Where:   ConnID = Connection number returned from previous LdapBind
   DN-to-delete = kind of self-explanatory isn't it?
Results:
      data: None
    errors: Invalid connection number!
            Unable to delete entry
  messages: Entry deleted
Return codes:
  success: TCL_OK
  failure: TCL_ERROR
Note: Each argument to the LdapDelete command can be a variable.
Example:
LdapDelete 0 "cn=Joe Doe,ou=org2,o=org1,c=us"
or
LdapDelete $connection $dn
/******************************************************************************/

/******************************************************************************/
Command:   LdapModRDN
Arguments: ConnID DN RDN ReplaceFlag(1=replace,0=add)
Where:   ConnID = Connection number returned from previous LdapBind
             DN = FULL DN of original entry
            RDN = RELATIVE dn of new name
    ReplaceFlag = replace or add new name (1=replace, 0=add)
Results:  
      data: None
    errors: Invalid connection number!
            Unable to rename entry
  messages: Entry renamed
Return codes:
  success: TCL_OK
  failure: TCL_ERROR
Note: Each argument to the LdapModRDN command can be a variable.
Example:
LdapModRDN 0 "cn=Joe Doe,ou=org2,o=org1,c=us" "cn=Joseph Doe" 1
or
LdapModRDN $connection $dn $rdn $flag
/******************************************************************************/

/******************************************************************************/
Command:   LdapModify/LdapAdd
Arguments: ConnID DN [LIST of attr=value pairs]
Where:   ConnID = Connection number returned from previous LdapBind
             DN = FULL DN of entry to change/add
     Attributes = A tcl LIST of attr=value pairs (This MUST be a list!)
Results:  
      data: None
    errors: Invalid connection number!
            No LIST argument passed
            Problem with data
            Unable to add entry (FOR THE ADD SUB-FUNCTION)
            Unable to change entry
  messages: None
Return codes:
  success: TCL_OK
  failure: TCL_ERROR
Note: Each argument to the LdapModify/LdapAdd command can be a variable.
Example:
LdapModify 0 "cn=Joe Doe,ou=org2,o=org1,c=us" [list "sn=Jones" "telephoneNumber=+1 999 555 1212"]
or
set attrs [list "sn=Jones" "telephoneNumber=+1 999 555 1212"]
LdapModify $connection $dn $attrs
----
LdapAdd 0 "cn=Joe Doe,ou=org2,o=org1,c=us" [list "sn=Jones" "telephoneNumber=+1 999 555 1212"]
or
set attrs [list "sn=Jones" "telephoneNumber=+1 999 555 1212"]
LdapAdd $connection $dn $attrs

P.S. For the LdapModify command, if you place a minus "-" sign in front of an
attr=value pair, the LdapModify command will delete that attr=value.
(i.e. [list "-telephoneNumber=+1 999 555 1212"] will delete the phone number).
/******************************************************************************/

/******************************************************************************/
Command:   LdapSearch
Arguments: ConnID Scope Deref BaseDN Filter [LIST of Attrs to return (optional)]
Where:   ConnID = Connection number returned from previous LdapBind
          Scope = One of "base, one, or sub" (default is subtree)
          Deref = One of "never, search, find, or always" (default is never)
         BaseDN = DN of the starting point for the search
         Filter = Standard LDAP-style search filter
     Attributes = A tcl LIST of attribute NAMES (This MUST be a list! If this
                  option is left off, ALL attributes will be returned.)
Results:
      data: A tcl LIST of attr=value pairs.
            (If more than one ENTRY is returned, then the sets of attr=value
            pairs are still returned as ONE list with a NULL list element
            separating the entries.)
    errors: Invalid connection number!
            No LIST argument passed!
            Search failed
            Search failed to find anything
  messages: None
Return codes:
  success: TCL_OK
  failure: TCL_ERROR
Note: Each argument to the LdapSearch command can be a variable.
Example:
LdapSearch 0 sub never "o=org1,c=us" "cn=Joseph Doe" [list "sn" "telephoneNumber"]
or
set attrs [list "sn" "telephoneNumber"]
LdapSearch $connection $scope $deref $base $filter $attrs
(The above search would do a subtree search starting in the o=org1,c=us
 directory using the filter cn=Joseph Doe and return the
 attributes "sn" and "telephoneNumber")
(The same search without the "$attrs" would automatically return everything.)
/******************************************************************************/

ENJOY!

please send any suggestions/code enhancements to:
tmurray@ix.netcom.com
(Tony Murray)