Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 418311 | Differences between
and this patch

Collapse All | Expand All

(-)lualdap-1.1.0/src/lualdap.c.orig (+27 lines)
Lines 461-467 Link Here
461
	luaL_argcheck(L, conn!=NULL, 1, LUALDAP_PREFIX"LDAP connection expected");
461
	luaL_argcheck(L, conn!=NULL, 1, LUALDAP_PREFIX"LDAP connection expected");
462
	if (conn->ld == NULL) /* already closed */
462
	if (conn->ld == NULL) /* already closed */
463
		return 0;
463
		return 0;
464
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && LDAP_API_FEATURE_X_OPENLDAP >= 20300
465
	ldap_unbind_ext (conn->ld, NULL, NULL);
466
#else
464
	ldap_unbind (conn->ld);
467
	ldap_unbind (conn->ld);
468
#endif
465
	conn->ld = NULL;
469
	conn->ld = NULL;
466
	lua_pushnumber (L, 1);
470
	lua_pushnumber (L, 1);
467
	return 1;
471
	return 1;
Lines 939-951 Link Here
939
	const char *password = luaL_optstring (L, 3, NULL);
947
	const char *password = luaL_optstring (L, 3, NULL);
940
	int use_tls = lua_toboolean (L, 4);
948
	int use_tls = lua_toboolean (L, 4);
941
	conn_data *conn = (conn_data *)lua_newuserdata (L, sizeof(conn_data));
949
	conn_data *conn = (conn_data *)lua_newuserdata (L, sizeof(conn_data));
950
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && LDAP_API_FEATURE_X_OPENLDAP >= 20300
951
	struct berval cred = { 0, NULL };
952
	char *host_with_schema = NULL;
953
#endif
942
	int err;
954
	int err;
943
955
944
	/* Initialize */
956
	/* Initialize */
945
	lualdap_setmeta (L, LUALDAP_CONNECTION_METATABLE);
957
	lualdap_setmeta (L, LUALDAP_CONNECTION_METATABLE);
946
	conn->version = 0;
958
	conn->version = 0;
959
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && LDAP_API_FEATURE_X_OPENLDAP >= 20300
960
	host_with_schema = malloc(strlen(host) + 8);
961
	strcpy(host_with_schema, "ldap://");
962
	strcat(host_with_schema, host);
963
	err = ldap_initialize(&conn->ld, host_with_schema);
964
	free(host_with_schema);
965
	host_with_schema = NULL;
966
	if (err != LDAP_SUCCESS)
967
#else
947
	conn->ld = ldap_init (host, LDAP_PORT);
968
	conn->ld = ldap_init (host, LDAP_PORT);
948
	if (conn->ld == NULL)
969
	if (conn->ld == NULL)
970
#endif
949
		return faildirect(L,LUALDAP_PREFIX"Error connecting to server");
971
		return faildirect(L,LUALDAP_PREFIX"Error connecting to server");
950
	/* Set protocol version */
972
	/* Set protocol version */
951
	conn->version = LDAP_VERSION3;
973
	conn->version = LDAP_VERSION3;
Lines 959-965 Link Here
959
			return faildirect (L, ldap_err2string (rc));
981
			return faildirect (L, ldap_err2string (rc));
960
	}
982
	}
961
	/* Bind to a server */
983
	/* Bind to a server */
984
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && LDAP_API_FEATURE_X_OPENLDAP >= 20300
985
	cred.bv_len = strlen(password);
986
	cred.bv_val = strdup(password);
987
	err = ldap_sasl_bind_s (conn->ld, who, LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL);
988
	free(cred.bv_val);
989
	cred.bv_len = 0;
990
	cred.bv_val = NULL;
991
#else
962
	err = ldap_bind_s (conn->ld, who, password, LDAP_AUTH_SIMPLE);
992
	err = ldap_bind_s (conn->ld, who, password, LDAP_AUTH_SIMPLE);
993
#endif
963
	if (err != LDAP_SUCCESS)
994
	if (err != LDAP_SUCCESS)
964
		return faildirect (L, ldap_err2string (err));
995
		return faildirect (L, ldap_err2string (err));
965
996

Return to bug 418311