This is the code I am using to connect to my LDAPserver. While compiling it doesn't show any errors, but in running the JVM is crashing. What is the problem with this code?
JNIEXPORT void JNICALL Java_Login_uInsert(JNIEnv *env, jclass mycls, jstring id, jstring fname, jstring lname), JNI generated header line.
{
LDAP *ldap = NULL;
const int version = LDAP_VERSION3;
const char* host = "localhost";
ldap = ldap_init(host,10389);
int result = ldap_set_option(ldap,LDAP_OPT_PROTOCOL_VERSION,&version);
const char *sid = env->GetStringUTFChars(id, NULL);
const char *sfname = env->GetStringUTFChars(fname, NULL);
LDAPMod a1,a2,a3;
char *dn="uid=1913015,ou=users,ou=system";
char *id_values;
strcpy(id_values,sid);
a1.mod_op=LDAP_MOD_ADD;
a1.mod_type="uid";
a1.mod_values=&id_values;
char *cn_values;
strcpy(cn_values,sfname);
a2.mod_op=LDAP_MOD_ADD;
a2.mod_type="cn";
a2.mod_values=&cn_values;
char *oc_values[] = {"inetOrgPerson", NULL};
a3.mod_op = LDAP_MOD_ADD;
a3.mod_type = "objectClass";
a3.mod_values = oc_values;
LDAPMod *entry[4];
entry[0]=&a1;
entry[1]=&a2;
entry[2]=&a3;
entry[3]=NULL;
ldap_add(ldap,dn,entry);
ldap_unbind(ldap);
}