Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Modules/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ LDAP_set_option(LDAPObject *self, int option, PyObject *value)
#ifdef HAVE_SASL
case LDAP_OPT_X_SASL_SSF_MIN:
case LDAP_OPT_X_SASL_SSF_MAX:
case LDAP_OPT_X_SASL_SSF_EXTERNAL:
if (!PyArg_Parse(value, "k:set_option", &blen))
return 0;
ptr = &blen;
Expand Down Expand Up @@ -261,6 +262,12 @@ LDAP_get_option(LDAPObject *self, int option)
Py_ssize_t i, num_extensions;

switch (option) {
#ifdef HAVE_SASL
case LDAP_OPT_X_SASL_SSF_EXTERNAL:
/* Write-only options */
PyErr_SetString(PyExc_ValueError, "write-only option");
return NULL;
#endif
case LDAP_OPT_API_INFO:
apiinfo.ldapai_info_version = LDAP_API_INFO_VERSION;
res = LDAP_int_get_option(self, option, &apiinfo);
Expand Down
3 changes: 3 additions & 0 deletions Tests/t_ldapobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ def test006_sasl_options(self):
self.assertEqual(l.get_option(ldap.OPT_X_SASL_SSF_MAX), 256)

l.sasl_external_bind_s()
with self.assertRaisesRegex(ValueError, "write-only option"):
l.get_option(ldap.OPT_X_SASL_SSF_EXTERNAL)
l.set_option(ldap.OPT_X_SASL_SSF_EXTERNAL, 256)
self.assertEqual(l.whoami_s(), 'dn:' + self.server.root_dn.lower())

def test007_timeout(self):
Expand Down