X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Fcyrus.c;h=0f635b2aad676daa7d3fcc221d7849f542aeeabb;hb=a5cad3f18a4b8fbbbb1bfc5db9d00022d9ebbfc4;hp=57d0304313c6da5b1f41ba10a476713e628e7108;hpb=5b34dfcbf69a00bc002cf1f0f3acad91062ebc3f;p=openldap diff --git a/libraries/libldap/cyrus.c b/libraries/libldap/cyrus.c index 57d0304313..0f635b2aad 100644 --- a/libraries/libldap/cyrus.c +++ b/libraries/libldap/cyrus.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2009 The OpenLDAP Foundation. + * Copyright 1998-2010 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1013,10 +1013,54 @@ 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_authctx; + + 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 ? LDAP_STRDUP( username ) : NULL; + } break; + case LDAP_OPT_X_SASL_SECPROPS: /* this option is write only */ return -1; +#ifdef SASL_GSS_CREDS + case LDAP_OPT_X_SASL_GSS_CREDS: { + sasl_conn_t *ctx; + int sc; + + if ( ld->ld_defconn == NULL ) + return -1; + + ctx = ld->ld_defconn->lconn_sasl_authctx; + if ( ctx == NULL ) + return -1; + + sc = sasl_getprop( ctx, SASL_GSS_CREDS, arg ); + if ( sc != SASL_OK ) + return -1; + } + break; +#endif + default: return -1; } @@ -1034,6 +1078,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; @@ -1098,6 +1143,25 @@ ldap_int_sasl_set_option( LDAP *ld, int option, void *arg ) return sc == LDAP_SUCCESS ? 0 : -1; } +#ifdef SASL_GSS_CREDS + case LDAP_OPT_X_SASL_GSS_CREDS: { + sasl_conn_t *ctx; + int sc; + + if ( ld->ld_defconn == NULL ) + return -1; + + ctx = ld->ld_defconn->lconn_sasl_authctx; + if ( ctx == NULL ) + return -1; + + sc = sasl_setprop( ctx, SASL_GSS_CREDS, arg ); + if ( sc != SASL_OK ) + return -1; + } + break; +#endif + default: return -1; }