Hi,
I am attempting to make an ldap_modify_s from an Objective C application running on a mac. When I attempt to make a test modification I get the error EXC_BAD_ACCESS which generally means that a variable has gone out of scope. However, I do not see how any of the variable involved could have fallen out of scope, so I'm not sure my mod syntax is correct...
LDAP *ld; ld = ldap_init(host, PORTNUMBER); char *user = NULL; char *pass = NULL;
int rc; rc = ldap_simple_bind_s( ld, user, pass ); LDAPMod *modM; char *dn = "uflEduUniversityId=28833300,ou=People,dc=ufl,dc=edu"; char** vals0; modM->mod_op = LDAP_MOD_REPLACE; modM->mod_type = "mail"; vals0[0] = "eric@ntu.ac.uk"; modM->mod_values = vals0; int i = ldap_modify_s(ld, dn, modM);
Host and port number are defined earlier in the script.
I know that I'm trying to do a modification with a null bind, but I would expect to see Invalid Credentials rather than an access error...
Does the syntax of this modification look like it 'should' work?
Many thanks, Ade
On Apr 26, 2009, at 5:31 AM, Adrian St. John-Bee wrote:
char** vals0;
...
vals0[0] = "eric@ntu.ac.uk";
It looks like these two lines are your problem.
You are just defining vals0 as a pointer to a pointer, and then referencing it as an array of pointers.
However, you don't allocate any memory to actually store any data into.
If you switched you're code to something like:
char* vals0[2]; vals0[0] = "eric@ntu.ac.uk"; vals0[1] = NULL;
I have no comment on whether you are using the ldap api's correctly or not.
I've changed the code to...
char* vals0[2]; vals0[0] = "eric@ntu.ac.uk"; vals0[1] = NULL;
int rc = ldap_simple_bind_s(ld, user, pass); LDAPMod *modM; char *dn = "uflEduUniversityId=28833300,ou=People,dc=ufl,dc=edu";
modM->mod_op = LDAP_MOD_ADD; modM->mod_type = "mail"; modM->mod_values = vals0; if((ldap_modify_s(ld, dn, &modM)) != LDAP_SUCCESS) { // FAIL }
But still get the same error on the ldap_modify_s(ld, dn, &modM) command.
Cheers, Ade
2009/4/27 Eli Bach ebach2@gmail.com:
On Apr 26, 2009, at 5:31 AM, Adrian St. John-Bee wrote:
char** vals0;
...
vals0[0] = "eric@ntu.ac.uk";
It looks like these two lines are your problem.
You are just defining vals0 as a pointer to a pointer, and then referencing it as an array of pointers.
However, you don't allocate any memory to actually store any data into.
If you switched you're code to something like:
char* vals0[2]; vals0[0] = "eric@ntu.ac.uk"; vals0[1] = NULL;
I have no comment on whether you are using the ldap api's correctly or not.
Adrian St. John-Bee wrote:
I've changed the code to...
Rather than just blindly changing things, you should try to understand what those things mean. You've made the same programming error twice, 'vals' was only one instance of the error. This list isn't for teaching you how to program in C.
char* vals0[2]; vals0[0] = "eric@ntu.ac.uk"; vals0[1] = NULL;
int rc = ldap_simple_bind_s(ld, user, pass);
LDAPMod *modM;
char *dn = "uflEduUniversityId=28833300,ou=People,dc=ufl,dc=edu";
modM->mod_op = LDAP_MOD_ADD; modM->mod_type = "mail"; modM->mod_values = vals0;
if((ldap_modify_s(ld, dn,&modM)) != LDAP_SUCCESS) { // FAIL }
But still get the same error on the ldap_modify_s(ld, dn,&modM) command.
Cheers, Ade
2009/4/27 Eli Bachebach2@gmail.com:
On Apr 26, 2009, at 5:31 AM, Adrian St. John-Bee wrote:
char** vals0;
...
vals0[0] = "eric@ntu.ac.uk";
It looks like these two lines are your problem.
You are just defining vals0 as a pointer to a pointer, and then referencing it as an array of pointers.
However, you don't allocate any memory to actually store any data into.
If you switched you're code to something like:
char* vals0[2]; vals0[0] = "eric@ntu.ac.uk"; vals0[1] = NULL;
I have no comment on whether you are using the ldap api's correctly or not.
On Sun, 26 Apr 2009, Adrian St. John-Bee wrote:
I am attempting to make an ldap_modify_s from an Objective C
Does Objective C perform automagic allocations?
[...]
char** vals0;
[...]
vals0[0] = "eric@ntu.ac.uk";
I'd have to ask that because I don't do Objective C. But in C99...well, try running that under valgrind, that's all I'll say...
openldap-software@openldap.org