]> git.sur5r.net Git - openldap/commitdiff
log formatOID, possibly mapped to friendly name if known
authorPierangelo Masarati <ando@openldap.org>
Wed, 22 Aug 2007 08:44:21 +0000 (08:44 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 22 Aug 2007 08:44:21 +0000 (08:44 +0000)
include/ldap.h
servers/slapd/controls.c

index 91be5e2ce301fd217ec3acfc7cb4bc195cdc75d4..2f217523d9972517e3b23bcd6d9547b39b31dbb2 100644 (file)
@@ -297,6 +297,12 @@ typedef struct ldapcontrol {
 #ifdef LDAP_DEVEL
 /* <draft-wahl-ldap-session> */
 #define LDAP_CONTROL_X_SESSION_TRACKING                "1.3.6.1.4.1.21008.108.63.1"
+#define LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_SESSION_ID \
+                                               LDAP_CONTROL_X_SESSION_TRACKING ".1"
+#define LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_MULTI_SESSION_ID \
+                                               LDAP_CONTROL_X_SESSION_TRACKING ".2"
+#define LDAP_CONTROL_X_SESSION_TRACKING_USERNAME \
+                                               LDAP_CONTROL_X_SESSION_TRACKING ".3"
 #endif /* LDAP_DEVEL */
 
 /* various expired works */
index 66743f7ccea027fa692533039cf7b682eaa04d32..5e8a6ecc925ae9c7ed8ad0d660851139ac34dcaf 100644 (file)
@@ -1606,6 +1606,17 @@ static int parseSearchOptions (
 }
 
 #ifdef SLAP_CONTROL_X_SESSION_TRACKING
+struct berval session_tracking_formats[] = {
+       BER_BVC( "LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_SESSION_ID" ),
+               BER_BVC( "RADIUS-Acct-Session-Id" ),
+       BER_BVC( LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_MULTI_SESSION_ID ),
+               BER_BVC( "RADIUS-Acct-Multi-Session-Id" ),
+       BER_BVC( LDAP_CONTROL_X_SESSION_TRACKING_USERNAME ),
+               BER_BVC( "USERNAME" ),
+
+       BER_BVNULL
+};
+
 static int parseSessionTracking(
        Operation *op,
        SlapReply *rs,
@@ -1614,7 +1625,7 @@ static int parseSessionTracking(
        BerElement              *ber;
        ber_tag_t               tag;
        ber_len_t               len;
-       int                     rc;
+       int                     i, rc;
 
        struct berval           sessionSourceIp = BER_BVNULL,
                                sessionSourceName = BER_BVNULL,
@@ -1723,6 +1734,14 @@ static int parseSessionTracking(
                goto error;
        }
 
+       for ( i = 0; !BER_BVISNULL( &session_tracking_formats[ i ] ); i += 2 )
+       {
+               if ( bvmatch( &formatOID, &session_tracking_formats[ i ] ) ) {
+                       formatOID = session_tracking_formats[ i + 1 ];
+                       break;
+               }
+       }
+
        /* sessionTrackingIdentifier */
        tag = ber_peek_tag( ber, &len );
        if ( tag == LBER_DEFAULT ) {
@@ -1739,7 +1758,8 @@ static int parseSessionTracking(
        }
 
        if ( ldif_is_not_printable( sessionTrackingIdentifier.bv_val, sessionTrackingIdentifier.bv_len ) ) {
-               BER_BVZERO( &sessionTrackingIdentifier );
+               /* we want the OID printed, at least */
+               BER_BVSTR( &sessionTrackingIdentifier, "" );
        }
 
        /* closure */
@@ -1758,7 +1778,8 @@ static int parseSessionTracking(
        }
        if ( !BER_BVISNULL( &sessionTrackingIdentifier ) ) {
                if ( st_len ) st_len++;
-               st_len += STRLENOF( "ID=" ) + sessionTrackingIdentifier.bv_len;
+               st_len += formatOID.bv_len + STRLENOF( "=" )
+                       + sessionTrackingIdentifier.bv_len;
        }
 
        if ( st_len == 0 ) {
@@ -1789,7 +1810,8 @@ static int parseSessionTracking(
 
                if ( !BER_BVISNULL( &sessionTrackingIdentifier ) ) {
                        if ( st_len ) *ptr++ = ' ';
-                       ptr = lutil_strcopy( ptr, "ID=" );
+                       ptr = lutil_strcopy( ptr, formatOID.bv_val );
+                       *ptr++ = '=';
                        ptr = lutil_strcopy( ptr, sessionTrackingIdentifier.bv_val );
                }