From b2432fdbf2b76baeeb6d8fea7b6b7d73420b4fec Mon Sep 17 00:00:00 2001
From: Howard Chu <hyc@openldap.org>
Date: Thu, 9 Oct 2008 09:28:39 +0000
Subject: [PATCH] Add SASL_MECHLIST option to retrieve list of known SASL mechs

---
 include/ldap.h            | 3 ++-
 libraries/libldap/cyrus.c | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/include/ldap.h b/include/ldap.h
index 7f87330dae..fb66dbb569 100644
--- a/include/ldap.h
+++ b/include/ldap.h
@@ -164,7 +164,8 @@ LDAP_BEGIN_DECL
 #define LDAP_OPT_X_SASL_SECPROPS		0x6106 /* write-only */
 #define LDAP_OPT_X_SASL_SSF_MIN			0x6107
 #define LDAP_OPT_X_SASL_SSF_MAX			0x6108
-#define	LDAP_OPT_X_SASL_MAXBUFSIZE		0x6109
+#define LDAP_OPT_X_SASL_MAXBUFSIZE		0x6109
+#define LDAP_OPT_X_SASL_MECHLIST		0x610a /* read-only */
 
 /* Private API Extensions -- reserved for application use */
 #define LDAP_OPT_PRIVATE_EXTENSION_BASE 0x7000  /* Private API inclusive */
diff --git a/libraries/libldap/cyrus.c b/libraries/libldap/cyrus.c
index c1fb06c5c5..d5779fd71f 100644
--- a/libraries/libldap/cyrus.c
+++ b/libraries/libldap/cyrus.c
@@ -1123,6 +1123,13 @@ ldap_int_sasl_config( struct ldapoptions *lo, int option, const char *arg )
 int
 ldap_int_sasl_get_option( LDAP *ld, int option, void *arg )
 {
+	if ( option == LDAP_OPT_X_SASL_MECHLIST ) {
+		if ( ldap_int_sasl_init() )
+			return -1;
+		*(char ***)arg = sasl_global_listmech();
+		return 0;
+	}
+
 	if ( ld == NULL )
 		return -1;