basic support for LDAPControls
This commit is contained in:
parent
610b9c5c00
commit
4ab9274132
99
c/ldap.c
99
c/ldap.c
|
@ -9,6 +9,8 @@ FFIT_MAKE_ENTER_RECORD(scsh_enter_ldapmessage, scsh_ldapmessage_record_type,
|
||||||
FFIT_MAKE_ENTER_RECORD(scsh_enter_ldapmod, scsh_ldapmod_record_type,
|
FFIT_MAKE_ENTER_RECORD(scsh_enter_ldapmod, scsh_ldapmod_record_type,
|
||||||
LDAPMod*);
|
LDAPMod*);
|
||||||
|
|
||||||
|
/* LDAPAPIInfo */
|
||||||
|
|
||||||
FFIT_MAKE_ENTER_RECORD(scsh_enter_ldapiinfo, scsh_ldapapiinfo_record_type,
|
FFIT_MAKE_ENTER_RECORD(scsh_enter_ldapiinfo, scsh_ldapapiinfo_record_type,
|
||||||
LDAPAPIInfo*);
|
LDAPAPIInfo*);
|
||||||
|
|
||||||
|
@ -36,6 +38,58 @@ FFIT_STRUCT_GET(scsh_ldapapiinfo_get_extensions,
|
||||||
scsh_ldapapiinfo_record_type, LDAPAPIInfo*,
|
scsh_ldapapiinfo_record_type, LDAPAPIInfo*,
|
||||||
ldapai_extensions, ffit_enter_string_array);
|
ldapai_extensions, ffit_enter_string_array);
|
||||||
|
|
||||||
|
/* LDAPControl */
|
||||||
|
|
||||||
|
FFIT_MAKE_ENTER_RECORD(scsh_enter_ldapcontrol, scsh_ldapcontrol_record_type,
|
||||||
|
LDAPControl*);
|
||||||
|
|
||||||
|
FFIT_STRUCT_GET_STRING(scsh_ldapcontrol_get_objectid,
|
||||||
|
scsh_ldapcontrol_record_type, LDAPControl*,
|
||||||
|
ldctl_oid);
|
||||||
|
|
||||||
|
FFIT_STRUCT_SET_STRING(scsh_ldapcontrol_set_objectid,
|
||||||
|
scsh_ldapcontrol_record_type, LDAPControl*,
|
||||||
|
ldctl_oid);
|
||||||
|
|
||||||
|
s48_value scsh_ldapcontrol_get_value(s48_value control)
|
||||||
|
{
|
||||||
|
LDAPControl* ctrl;
|
||||||
|
s48_value bytes;
|
||||||
|
S48_DECLARE_GC_PROTECT(2);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_2(control, bytes);
|
||||||
|
ctrl = scsh_extract_ldapcontrol(control);
|
||||||
|
bytes = scsh_enter_BerValue_as_bytevector(&(ctrl->ldctl_value));
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
s48_value scsh_ldapcontrol_set_value(s48_value control, s48_value value)
|
||||||
|
{
|
||||||
|
BerValue* bv;
|
||||||
|
LDAPControl* ctrl;
|
||||||
|
S48_DECLARE_GC_PROTECT(2);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_2(control, value);
|
||||||
|
ctrl = scsh_extract_ldapcontrol(control);
|
||||||
|
bv = scsh_extract_bytevector_as_BerValue(value);
|
||||||
|
(ctrl->ldctl_value).bv_len = bv->bv_len;
|
||||||
|
(ctrl->ldctl_value).bv_val = bv->bv_val;
|
||||||
|
free(bv);
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
return S48_UNSPECIFIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
FFIT_STRUCT_GET_CHAR(scsh_ldapcontrol_get_iscritical,
|
||||||
|
scsh_ldapcontrol_record_type, LDAPControl*,
|
||||||
|
ldctl_iscritical);
|
||||||
|
|
||||||
|
FFIT_STRUCT_SET_CHAR(scsh_ldapcontrol_set_iscritical,
|
||||||
|
scsh_ldapcontrol_record_type, LDAPControl*,
|
||||||
|
ldctl_iscritical);
|
||||||
|
|
||||||
|
/* BerElement */
|
||||||
|
|
||||||
FFIT_MAKE_ENTER_RECORD(scsh_enter_berelement, scsh_berelement_record_type,
|
FFIT_MAKE_ENTER_RECORD(scsh_enter_berelement, scsh_berelement_record_type,
|
||||||
BerElement *);
|
BerElement *);
|
||||||
|
|
||||||
|
@ -74,6 +128,16 @@ s48_value scsh_ldap_sasl_bind_s(s48_value ldap, s48_value dn,
|
||||||
s48_value client_controls,
|
s48_value client_controls,
|
||||||
s48_value server_cred_p)
|
s48_value server_cred_p)
|
||||||
{
|
{
|
||||||
|
LDAP *l;
|
||||||
|
BerValue *bv;
|
||||||
|
int ret;
|
||||||
|
S48_DECLARE_GC_PROTECT(8);
|
||||||
|
|
||||||
|
bv = scsh_extract_bytevector_as_BerValue(cred);
|
||||||
|
|
||||||
|
l = scsh_extract_ldap(ldap);
|
||||||
|
|
||||||
|
|
||||||
/* need to implement bindings for berval stuff first */
|
/* need to implement bindings for berval stuff first */
|
||||||
return S48_FALSE;
|
return S48_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -619,13 +683,13 @@ LDAPMod** scsh_extract_ldapmod_list(s48_value list)
|
||||||
S48_DECLARE_GC_PROTECT(2);
|
S48_DECLARE_GC_PROTECT(2);
|
||||||
|
|
||||||
S48_GC_PROTECT_2(list, e);
|
S48_GC_PROTECT_2(list, e);
|
||||||
l = length_scheme_list(list);
|
l = s48_length(list);
|
||||||
|
|
||||||
if ((a = (LDAPMod **) calloc(l + 1, sizeof(LDAPMod *))) == NULL)
|
if ((a = (LDAPMod **) calloc(l + 1, sizeof(LDAPMod *))) == NULL)
|
||||||
s48_raise_out_of_memory_error();
|
s48_raise_out_of_memory_error();
|
||||||
a[l] = NULL;
|
a[l] = NULL;
|
||||||
|
|
||||||
for (e = list, i = 0; e != NULL; e = S48_CDR(e), i++)
|
for (e = list, i = 0; e != S48_NULL; e = S48_CDR(e), i++)
|
||||||
a[i] = scsh_create_ldapmod(S48_CAR(e));
|
a[i] = scsh_create_ldapmod(S48_CAR(e));
|
||||||
|
|
||||||
S48_GC_UNPROTECT();
|
S48_GC_UNPROTECT();
|
||||||
|
@ -642,6 +706,37 @@ void scsh_free_ldapmod_array(LDAPMod **a)
|
||||||
free(a);
|
free(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s48_value scsh_enter_BerValue_as_bytevector(BerValue* bv)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
s48_value res = S48_FALSE;
|
||||||
|
S48_DECLARE_GC_PROTECT(1);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_1(res);
|
||||||
|
|
||||||
|
res = s48_make_byte_vector(bv->bv_len, 0);
|
||||||
|
for (i = 0; i < bv->bv_len; i++)
|
||||||
|
S48_BYTE_VECTOR_SET(res, i, bv->bv_val[i]);
|
||||||
|
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
BerValue* scsh_extract_bytevector_as_BerValue(s48_value bytevector)
|
||||||
|
{
|
||||||
|
BerValue* bv;
|
||||||
|
S48_DECLARE_GC_PROTECT(1);
|
||||||
|
|
||||||
|
S48_GC_PROTECT_1(bytevector);
|
||||||
|
if ((bv = (BerValue*) malloc(sizeof(BerValue))) == NULL)
|
||||||
|
s48_raise_out_of_memory_error();
|
||||||
|
|
||||||
|
bv->bv_val = s48_extract_byte_vector(bytevector);
|
||||||
|
bv->bv_len = S48_BYTE_VECTOR_LENGTH(bytevector);
|
||||||
|
S48_GC_UNPROTECT();
|
||||||
|
return bv;
|
||||||
|
}
|
||||||
|
|
||||||
void raise_ldap_memory_alloc_error(void)
|
void raise_ldap_memory_alloc_error(void)
|
||||||
{
|
{
|
||||||
s48_raise_scheme_exception(condition_ldap_memory_alloc_error, 0);
|
s48_raise_scheme_exception(condition_ldap_memory_alloc_error, 0);
|
||||||
|
|
|
@ -25,6 +25,7 @@ static s48_value scsh_ldapmessage_record_type = S48_FALSE;
|
||||||
static s48_value scsh_ldapmod_record_type = S48_FALSE;
|
static s48_value scsh_ldapmod_record_type = S48_FALSE;
|
||||||
static s48_value scsh_ldapapiinfo_record_type = S48_FALSE;
|
static s48_value scsh_ldapapiinfo_record_type = S48_FALSE;
|
||||||
static s48_value scsh_berelement_record_type = S48_FALSE;
|
static s48_value scsh_berelement_record_type = S48_FALSE;
|
||||||
|
static s48_value scsh_ldapcontrol_record_type = S48_FALSE;
|
||||||
|
|
||||||
FFIT_MAKE_ENTER_RECORD_PROTOTYPE(scsh_enter_ldap, LDAP*);
|
FFIT_MAKE_ENTER_RECORD_PROTOTYPE(scsh_enter_ldap, LDAP*);
|
||||||
#define scsh_extract_ldap(x) \
|
#define scsh_extract_ldap(x) \
|
||||||
|
@ -55,6 +56,11 @@ FFIT_MAKE_ENTER_RECORD_PROTOTYPE(scsh_enter_berelement, BerElement*);
|
||||||
((BerElement *) \
|
((BerElement *) \
|
||||||
s48_extract_integer(S48_RECORD_REF(x, 0)))
|
s48_extract_integer(S48_RECORD_REF(x, 0)))
|
||||||
|
|
||||||
|
FFIT_MAKE_ENTER_RECORD_PROTOTYPE(scsh_enter_ldapcontrol_record_type, LDAPControl*);
|
||||||
|
#define scsh_extract_ldapcontrol(x) \
|
||||||
|
((LDAPControl *) \
|
||||||
|
s48_extract_integer(S48_RECORD_REF(x, 0)))
|
||||||
|
|
||||||
/* conditions */
|
/* conditions */
|
||||||
static s48_value condition_ldap_memory_alloc_error = S48_FALSE;
|
static s48_value condition_ldap_memory_alloc_error = S48_FALSE;
|
||||||
static s48_value condition_ldap_feature_not_supported = S48_FALSE;
|
static s48_value condition_ldap_feature_not_supported = S48_FALSE;
|
||||||
|
@ -115,4 +121,6 @@ s48_value scsh_ldap_get_set_option(s48_value, s48_value, s48_value, s48_value);
|
||||||
LDAPMod* scsh_create_ldapmod(s48_value ldapmod);
|
LDAPMod* scsh_create_ldapmod(s48_value ldapmod);
|
||||||
LDAPMod** scsh_extract_ldapmod_list(s48_value);
|
LDAPMod** scsh_extract_ldapmod_list(s48_value);
|
||||||
void scsh_free_ldapmod_array(LDAPMod **);
|
void scsh_free_ldapmod_array(LDAPMod **);
|
||||||
|
s48_value scsh_enter_BerValue_as_bytevector(BerValue* bv);
|
||||||
|
BerValue* scsh_extract_bytevector_as_BerValue(s48_value bytevector);
|
||||||
void scsh_init_ldap_bindings(void);
|
void scsh_init_ldap_bindings(void);
|
||||||
|
|
Loading…
Reference in New Issue