Hello all,
I am having problems to compile the code below with C++, in the version oldest of the OpenLdap I did not have this problem.
=============code==================== extern "C" { #include <stdio.h> #include <ldap.h> }
#define HOSTNAME "ldap://ldap.cb.sc.gov.br:389" #define PORTNUMBER 389
int main(int argc, char *argv[]) { LDAP *ld; char *dn; int version, rc;
const char *root_dn = "uid=edm,ou=Users,dc=cb,dc=sc,dc=gov,dc=br"; char *root_pass = "passtest";
printf("Connecting %s in port %d...\n\n", HOSTNAME, PORTNUMBER);
rc = ldap_initialize(&ld, HOSTNAME); if ( rc != LDAP_SUCCESS ) { printf("Error !"); }
version = LDAP_VERSION3; ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &version);
rc = ldap_simple_bind_s(ld, root_dn, root_pass, LDAP_AUTH_SIMPLE ); if (rc != LDAP_SUCCESS) {
fprintf(stderr, "Error: %s\n", ldap_err2string(rc));
return (1);
}
ldap_unbind(ld); return(0); } ============end====================
% c++ -I/usr/local/include -L/usr/local/lib -lldap test_ldap.cpp -o test_ldap test_ldap.cpp: In function `int main(int, char**)': test_ldap.cpp:31: error: `ldap_simple_bind_s' was not declared in this scope test_ldap.cpp:40: error: `ldap_unbind' was not declared in this scope
devel:% uname -a FreeBSD devel.cb.sc.gov.br 6.2-STABLE FreeBSD 6.2-STABLE #0: Mon May 28 08:58:45 BRT 2007 root@devel.cb.sc.gov.br:/usr/src/sys/i386/compile/DEVEL i386
Used --> openldap-client-2.3.35 Open source LDAP client implementation
One another question, exists a API of the OpenLdap for C++?
Thanks, edm.
On Tuesday 19 June 2007 14:57, Eder wrote:
Hello all,
I am having problems to compile the code below with C++, in the version oldest of the OpenLdap I did not have this problem.
=============code====================
[..]
============end====================
% c++ -I/usr/local/include -L/usr/local/lib -lldap test_ldap.cpp -o test_ldap test_ldap.cpp: In function `int main(int, char**)': test_ldap.cpp:31: error: `ldap_simple_bind_s' was not declared in this scope test_ldap.cpp:40: error: `ldap_unbind' was not declared in this scope
Those function have been deprecated sometime ago. You should be using non-deprecated functions which would be "ldap_unbind_ext()" and "ldap_sasl_bind_s()". For more details you should probably search the list archives as this topic has already come up several times. And you might wanna check this little howto: http://opensuse.org/OpenLDAP_2.3_libldap_upgrade_howto
devel:% uname -a FreeBSD devel.cb.sc.gov.br 6.2-STABLE FreeBSD 6.2-STABLE #0: Mon May 28 08:58:45 BRT 2007 root@devel.cb.sc.gov.br:/usr/src/sys/i386/compile/DEVEL i386
Used --> openldap-client-2.3.35 Open source LDAP client implementation
One another question, exists a API of the OpenLdap for C++?
Yes. It's part of OpenLDAP since 2.1 (or even 2.0). You'll find it in the contrib directory of the source tarball.
regards, Ralf
Ok Ralf,
The functions "ldap_sasl_bind_s()", "ldap_sasl_bind_s()" had functioned now !
Thanks, edm.
On 6/19/07, Ralf Haferkamp rhafer@suse.de wrote:
On Tuesday 19 June 2007 14:57, Eder wrote:
Hello all,
I am having problems to compile the code below with C++, in the version oldest of the OpenLdap I did not have this problem.
=============code====================
[..]
============end====================
% c++ -I/usr/local/include -L/usr/local/lib -lldap test_ldap.cpp -o test_ldap test_ldap.cpp: In function `int main(int, char**)': test_ldap.cpp:31: error: `ldap_simple_bind_s' was not declared in this scope test_ldap.cpp:40: error: `ldap_unbind' was not declared in this scope
Those function have been deprecated sometime ago. You should be using non-deprecated functions which would be "ldap_unbind_ext()" and "ldap_sasl_bind_s()". For more details you should probably search the list archives as this topic has already come up several times. And you might wanna check this little howto: http://opensuse.org/OpenLDAP_2.3_libldap_upgrade_howto
devel:% uname -a FreeBSD devel.cb.sc.gov.br 6.2-STABLE FreeBSD 6.2-STABLE #0: Mon May 28 08:58:45 BRT 2007 root@devel.cb.sc.gov.br:/usr/src/sys/i386/compile/DEVEL i386
Used --> openldap-client-2.3.35 Open source LDAP client implementation
One another question, exists a API of the OpenLdap for C++?
Yes. It's part of OpenLDAP since 2.1 (or even 2.0). You'll find it in the contrib directory of the source tarball.
regards, Ralf
-- SUSE LINUX Products GmbH, Maxfeldstrasse 5, D-90409 Nuernberg T: +49-911-74053-0 F: +49-911-74053575 - Ralf.Haferkamp@suse.com
openldap-software@openldap.org