]> git.sur5r.net Git - openldap/commitdiff
expose SASL_USERNAME when it makes sense (EXTERN needs work, much like SASL_SSL)...
authorPierangelo Masarati <ando@openldap.org>
Tue, 18 Aug 2009 18:47:56 +0000 (18:47 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 18 Aug 2009 18:47:56 +0000 (18:47 +0000)
include/ldap.h
libraries/libldap/cyrus.c

index ca748a23a07b03f04d368de6d8f1af113232dab8..5cda775cfd3da464368825f7a7193e7fa1cd19c7 100644 (file)
@@ -186,6 +186,7 @@ LDAP_BEGIN_DECL
 #define LDAP_OPT_X_SASL_MAXBUFSIZE             0x6109
 #define LDAP_OPT_X_SASL_MECHLIST               0x610a /* read-only */
 #define LDAP_OPT_X_SASL_NOCANON                        0x610b
+#define LDAP_OPT_X_SASL_USERNAME               0x610c /* read-only */
 
 /* OpenLDAP GSSAPI options */
 #define LDAP_OPT_X_GSSAPI_DO_NOT_FREE_CONTEXT      0x6200
index 57d0304313c6da5b1f41ba10a476713e628e7108..c2a4b262896d6356414e78d79deb87486bdf6be5 100644 (file)
@@ -1013,6 +1013,31 @@ ldap_int_sasl_get_option( LDAP *ld, int option, void *arg )
                        *(int *)arg = (int) LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_SASL_NOCANON );
                        break;
 
+               case LDAP_OPT_X_SASL_USERNAME: {
+                       int sc;
+                       char *username;
+                       sasl_conn_t *ctx;
+
+                       if( ld->ld_defconn == NULL ) {
+                               return -1;
+                       }
+
+                       ctx = ld->ld_defconn->lconn_sasl_sockctx;
+
+                       if ( ctx == NULL ) {
+                               return -1;
+                       }
+
+                       sc = sasl_getprop( ctx, SASL_USERNAME,
+                               (SASL_CONST void **)(char **) &username );
+
+                       if ( sc != SASL_OK ) {
+                               return -1;
+                       }
+
+                       *(char **)arg = username;
+               } break;
+
                case LDAP_OPT_X_SASL_SECPROPS:
                        /* this option is write only */
                        return -1;
@@ -1034,6 +1059,7 @@ ldap_int_sasl_set_option( LDAP *ld, int option, void *arg )
 
        switch ( option ) {
        case LDAP_OPT_X_SASL_SSF:
+       case LDAP_OPT_X_SASL_USERNAME:
                /* This option is read-only */
                return -1;