c000755 007656 000017 00000000000 06441110015 011360 5ustar00donnusers000000 000000 c/staff.html000644 007656 000017 00000003036 06331732105 013442 0ustar00donnusers000000 000000
Test LDAP Staff Directory

Data

This is the staff directory as of about April 21, converted to LDAP LDIF format, and then to a ldbm backend data base served by University of Michigan's slapd.

All keys are searchable, but only some are indexed. This means that searching by street address, for example, is possible, but it won't be nearly as fast as searching by name or e-mail address. I haven't put any non-indexed keys on this page.

In the LDAP data, I've used attributes that the University of Michigan uses in their own directory. A good rationale for the selection of attributes (keys) is one area for further research.

Wild cards

You may use * as a wild card anywhere in your query, to match anything - for example, if there is an entry that matches the full name ``Joe Btflsnk'', it will also match the full name ``* Btflsnk''.

Combination

As you supply values for different fields, you are narrowing the search.

Search full name:

Search last name: Sounds like

Search first name: Sounds like

Search email address:

Search department:

c/httpdecode000755 007656 000017 00000001416 06331731225 013524 0ustar00donnusers000000 000000 #!/bin/awk -f # # Decode CGI form results for shell etc. processing. function hex2dec(x, h, n, l, i) { h = "0123456789ABCDEF..........abcdef" for (i = l = length(x); i > 0; i--) n += (index(h, substr(x, i, 1)) - 1) % 16 * 16 ^ (l - i) return n } function dehex(string, nstr, xstr, d) { xstr = string nstr = "" while (xstr) { d = match(xstr, "%[0-9A-Fa-f][0-9A-Fa-f]") if (d) { nstr = nstr substr(xstr, 1, d - 1) \ sprintf("%c", hex2dec(substr(xstr, d + 1, 2))) xstr = substr(xstr, d + 3) } else { nstr = nstr xstr xstr = "" } } return nstr } { # Transform + to SP gsub("[+]", " ") # Transform & to : (easier separator for shell) gsub("[&]", ":") # Delete presumably trailing CR. gsub("[\r]", "") print dehex($0) } c/ldapform2filt000755 007656 000017 00000001762 06327205062 014152 0ustar00donnusers000000 000000 #!/bin/awk -f # # Convert input like "cn=:sn=campbell:snapprox=on:ou=Tool Shed" # into LDAP filter: "(&(sn~=campbell)(ou=Tool Shed))" # BEGIN { FS=":" } { # Split each field on "=". # If the left side is like "cnapprox", then put the right hand # in soundslike["cn"], otherwise put in search array. for (i = 1; i <= NF; i++) { n = split($i, a, "=") if (n == 2 && a[2] != "") { if (a[1] ~ /approx/) { x = substr(a[1], 0, length(a[1]) - length("approx")) soundslike[x] = a[2] } else search[a[1]] = a[2] } } } END { # Pack up filter from search array. # search[k] = v --> (k=v) or (k~=v) if soundslike[k] == "on" # Multiple expressions are combined with logical "and": # (&(expr1)(expr2)...) # out = "" i = 0 for (key in search) { i = i + 1 v = search[key] if (key == "mail" && v !~ /@/ && v !~ /\*/) v = v "@*" if (soundslike[key]) eq = "~=" else eq = "=" out = out "(" key eq v ")" } if (i > 1) out = "(&" out ")" print out } c/ldapstdir.cgi000755 007656 000017 00000002024 06331731631 014125 0ustar00donnusers000000 000000 #!/bin/sh # # CGI to handle LDAP staff directory form. # Expects input in the form of a legitimate LDAP query. # Parses ldapsearch output. Could just filter it to output, but # then we'd be at the mercy of the LDAP data stream, which doesn't # have any particular structure that I can see. # echo Content-type: text/html echo echo '' echo '
' echo '' echo 'LDAP Staff/Student Directory Search Results' echo '' echo '
' echo '' echo '

LDAP Staff/Student Directory Search Results

' echo case $PATH_INFO in *staff*) echo '

(Staff Directory)

';; *student*) echo '

(Student Directory)

';; esac BINDIR=/usr/local/htdocs/cgi-bin read line search="`echo $line | $BINDIR/httpdecode | $BINDIR/ldapform2filt`" # Execute ldapsearch, read results. echo "

/usr/local/bin/ldapsearch -h staffdir \"$search\"

" echo '
' echo '
'

	/usr/local/bin/ldapsearch -h staffdir "$search" | $BINDIR/ldaptohtml

	echo '
' echo '' echo '' c/ldaptohtml000755 007656 000017 00000001302 06326773101 013546 0ustar00donnusers000000 000000 #!/bin/awk -f BEGIN { rep["cn"] = "Name" rep["sn"] = "X" rep["givenname"] = "X" rep["ou"] = "Department" rep["title"] = "Title" rep["postaladdress"] = "Address" rep["telephonenumber"] = "Phone" rep["mail"] = "Email" rep["mailstop"] = "Mailbox" rep["facsimiletelephonenumber"] = "FAX" rep["touchdialtelephonenumber"] = "TDD" rep["voicemailtelephonenumber"] = "Voice mail" rep["uid"] = "User name" rep["objectclass"] = "X" } { n = split($0, kv, "=") if (n > 2 && kv[1] == "cn") { split(kv[2], f, ",") printf "\n %s\n\n", f[1] } else if (n > 1 && kv[2] != "") { r = rep[kv[1]] if (r != "X") { if (r == "") r = kv[1] r = r ":" printf "%-11s %s\n", r, kv[2] } } } c/staff.html000644 007656 000017 00000003036 06331732105 013442 0ustar00donnusers000000 000000
Test LDAP Staff Directory

Data

This is the staff directory as of about April 21, converted to LDAP LDIF format, and then to a ldbm backend data base served by University of Michigan's slapd.

All keys are searchable, but only some are indexed. This means that searching by street address, for example, is possible, but it won't be nearly as fast as searching by name or e-mail address. I haven't put any non-indexed keys on this page.

In the LDAP data, I've used attributes that the University of Michigan uses in their own directory. A good rationale for the selection of attributes (keys) is one area for further research.

Wild cards

You may use * as a wild card anywhere in your query, to match anything - for example, if there is an entry that matches the full name ``Joe Btflsnk'', it will also match the full name ``* Btflsnk''.

Combination

As you supply values for different fields, you are narrowing the search.

Search full name:

Search last name: Sounds like

Search first name: Sounds like

Search email address:

Search department:

c/httpdecode000755 007656 000017 00000001416 06331731225 013524 0ustar00donnusers000000 000000 #!/bin/awk -f # # Decode CGI form results for shell etc. processing. function hex2dec(x, h, n, l, i) { h = "0123456789ABCDEF..........abcdef" for (i = l = length(x); i > 0; i--) n += (index(h, substr(x, i, 1)) - 1) % 16 * 16 ^ (l - i) return n } function dehex(string, nstr, xstr, d) { xstr = string nstr = "" while (xstr) { d = match(xstr, "%[0-9A-Fa-f][0-9A-Fa-f]") if (d) { nstr = nstr substr(xstr, 1, d - 1) \ sprintf("%c", hex2dec(substr(xstr, d + 1, 2))) xstr = substr(xstr, d + 3) } else { nstr = nstr xstr xstr = "" } } return nstr } { # Transform + to SP gsub("[+]", " ") # Transform & to : (easier separator for shell) gsub("[&]", ":") # Delete presumably trailing CR. gsub("[\r]", "") print dehex($0) } c/ldapform2filt000755 007656 000017 00000001762 06327205062 014152 0ustar00donnusers000000 000000 #!/bin/awk -f # # Convert input like "cn=:sn=campbell:snapprox=on:ou=Tool Shed" # into LDAP filter: "(&(sn~=campbell)(ou=Tool Shed))" # BEGIN { FS=":" } { # Split each field on "=". # If the left side is like "cnapprox", then put the right hand # in soundslike["cn"], otherwise put in search array. for (i = 1; i <= NF; i++) { n = split($i, a, "=") if (n == 2 && a[2] != "") { if (a[1] ~ /approx/) { x = substr(a[1], 0, length(a[1]) - length("approx")) soundslike[x] = a[2] } else search[a[1]] = a[2] } } } END { # Pack up filter from search array. # search[k] = v --> (k=v) or (k~=v) if soundslike[k] == "on" # Multiple expressions are combined with logical "and": # (&(expr1)(expr2)...) # out = "" i = 0 for (key in search) { i = i + 1 v = search[key] if (key == "mail" && v !~ /@/ && v !~ /\*/) v = v "@*" if (soundslike[key]) eq = "~=" else eq = "=" out = out "(" key eq v ")" } if (i > 1) out = "(&" out ")" print out } c/ldapstdir.cgi000755 007656 000017 00000002024 06331731631 014125 0ustar00donnusers000000 000000 #!/bin/sh # # CGI to handle LDAP staff directory form. # Expects input in the form of a legitimate LDAP query. # Parses ldapsearch output. Could just filter it to output, but # then we'd be at the mercy of the LDAP data stream, which doesn't # have any particular structure that I can see. # echo Content-type: text/html echo echo '' echo '
' echo '' echo 'LDAP Staff/Student Directory Search Results' echo '' echo '
' echo '' echo '

LDAP Staff/Student Directory Search Results

' echo case $PATH_INFO in *staff*) echo '

(Staff Directory)

';; *student*) echo '

(Student Directory)

';; esac BINDIR=/usr/local/htdocs/cgi-bin read line search="`echo $line | $BINDIR/httpdecode | $BINDIR/ldapform2filt`" # Execute ldapsearch, read results. echo "

/usr/local/bin/ldapsearch -h staffdir \"$search\"

" echo '
' echo '
'

	/usr/local/bin/ldapsearch -h staffdir "$search" | $BINDIR/ldaptohtml

	echo '
' echo '' echo '' c/ldaptohtml000755 007656 000017 00000001302 06326773101 013546 0ustar00donnusers000000 000000 #!/bin/awk -f BEGIN { rep["cn"] = "Name" rep["sn"] = "X" rep["givenname"] = "X" rep["ou"] = "Department" rep["title"] = "Title" rep["postaladdress"] = "Address" rep["telephonenumber"] = "Phone" rep["mail"] = "Email" rep["mailstop"] = "Mailbox" rep["facsimiletelephonenumber"] = "FAX" rep["touchdialtelephonenumber"] = "TDD" rep["voicemailtelephonenumber"] = "Voice mail" rep["uid"] = "User name" rep["objectclass"] = "X" } { n = split($0, kv, "=") if (n > 2 && kv[1] == "cn") { split(kv[2], f, ",") printf "\n %s\n\n", f[1] } else if (n > 1 && kv[2] != "") { r = rep[kv[1]] if (r != "X") { if (r == "") r = kv[1] r = r ":" printf "%-11s %s\n", r, kv[2] } } }