[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: syntax of ldap_modify_s

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.


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.

  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/