Adding objects to LDAP via CGI
Posted
by musashiXXX
on Stack Overflow
See other posts from Stack Overflow
or by musashiXXX
Published on 2010-03-27T12:42:17Z
Indexed on
2010/03/27
12:53 UTC
Read the original article
Hit count: 246
I have a web form that collects information and submits it to a cgi that attempts to insert the data into LDAP. The problem is that I'm trying to use a variable with ::ldap::add and it's just not working. Here's the code:
if {[string length env(QUERY_STRING)] != 0} {
set handle [::ldap::connect localhost]
set dn "cn=admin,dc=mycompany,dc=com"
set pw "myPassword"
::ldap::bind $handle $dn $pw
set dn "cn=[ncgi::value givenName] [ncgi::value sn],ou=people,dc=mycompany,dc=com"
set formValues [
puts "cn {{[ncgi::value givenName] [ncgi::value sn]}}"
puts "displayName [ncgi::value givenName] [ncgi::value sn]"
foreach {key value} [ncgi::nvlist] {
if {[string length $value] != 0} {
puts "$key $value"
}
}
puts "objectClass top"
puts "objectClass person"
puts "objectClass organizationalPerson"
puts "objectClass inetOrgPerson"
]
::ldap::add $handle $dn {
$formValues
}
ldap::unbind $handle
}
However, if I replace $formValues with the actual entries that I want to insert into LDAP, they get added just fine.
I'm new to TCL so I wouldn't be surprised if there were some glaring errors in this snippet.
Thanks in advance!
© Stack Overflow or respective owner