]> git.sur5r.net Git - openldap/commitdiff
Added slapi_connection_set_pb() API for front-end.
authorLuke Howard <lukeh@openldap.org>
Sun, 19 Jan 2003 14:32:49 +0000 (14:32 +0000)
committerLuke Howard <lukeh@openldap.org>
Sun, 19 Jan 2003 14:32:49 +0000 (14:32 +0000)
Implemented slapi_is_connection-ssl().

servers/slapd/slapi/slapi_utils.c
servers/slapd/slapi/slapi_utils.h

index bb30d95df610d94fc76512f487d553d1fa770810..86bd68ac3360a819931cb0553d77f17fa52e694b 100644 (file)
@@ -1130,3 +1130,55 @@ slapi_free_search_results_internal( Slapi_PBlock *pb )
 #endif /* defined(LDAP_SLAPI) */
 }
 
+/*
+ * Internal API to prime a Slapi_PBlock with a Connection.
+ */
+void slapi_connection_set_pb( Slapi_PBlock *pb, Connection *conn )
+{
+#if defined(LDAP_SLAPI)
+       char *connAuthType;
+       size_t len;
+
+       slapi_pblock_set(pb, SLAPI_CONNECTION, conn);
+       slapi_pblock_set(pb, SLAPI_CONN_ID, (void *)conn->c_connid);
+       switch (conn->c_authz.sai_method) {
+       case LDAP_AUTH_SASL: 
+               len = sizeof(SLAPD_AUTH_SASL) + conn->c_authz.sai_mech.bv_len;
+               connAuthType = slapi_ch_malloc(len);
+               snprintf(connAuthType, len, "%s%s", SLAPD_AUTH_SASL, conn->c_authz.sai_mech.bv_val);
+               break;
+       case LDAP_AUTH_SIMPLE:
+               connAuthType = slapi_ch_strdup(SLAPD_AUTH_SIMPLE);
+               break;
+       case LDAP_AUTH_NONE:
+               connAuthType = slapi_ch_strdup(SLAPD_AUTH_NONE);
+               break;
+       default:
+               connAuthType = NULL;
+               break;
+       }
+       if (conn->c_is_tls && connAuthType == NULL) {
+               connAuthType = slapi_ch_strdup(SLAPD_AUTH_SSL);
+       }
+       if (connAuthType != NULL) {
+               slapi_pblock_set(pb, SLAPI_CONN_AUTHTYPE, connAuthType);
+       }
+       if (conn->c_authz.sai_dn.bv_val != NULL) {
+               slapi_pblock_set(pb, SLAPI_CONN_DN, slapi_ch_strdup(conn->c_authz.sai_dn.bv_val));
+       }
+#endif /* defined(LDAP_SLAPI) */
+}
+
+int slapi_is_connection_ssl( Slapi_PBlock *pb, int *isSSL )
+{
+#if defined( LDAP_SLAPI )
+       Connection *conn;
+
+       slapi_pblock_get( pb, SLAPI_CONNECTION, &conn );
+       *isSSL = conn->c_is_tls;
+
+       return LDAP_SUCCESS;
+#else
+       return -1;
+#endif /* defined(LDAP_SLAPI) */
+}
index 186c5a4b51bad103600675c4b0bc6af84878805a..9820eab2c5e3860ee2b62f771bf77a044da80de1 100644 (file)
@@ -107,6 +107,7 @@ int slapi_audit_init_header( Connection *conn, Operation *op,
                int audit_op, int audit_ext_op, int audit_op_str_len); 
 int slapi_audit_send_record( Slapi_PBlock *pb, Connection *conn, 
                                                Operation *op, int rc);
+void slapi_connection_set_pb( Slapi_PBlock *pb, Connection *conn );
 
 extern ldap_pvt_thread_mutex_t slapi_hn_mutex;
 extern ldap_pvt_thread_mutex_t slapi_time_mutex;