]> git.sur5r.net Git - openldap/commitdiff
added slapi_operation_set_pb
authorLuke Howard <lukeh@openldap.org>
Sun, 19 Jan 2003 14:47:26 +0000 (14:47 +0000)
committerLuke Howard <lukeh@openldap.org>
Sun, 19 Jan 2003 14:47:26 +0000 (14:47 +0000)
servers/slapd/slapi/slapi_utils.c
servers/slapd/slapi/slapi_utils.h

index 86bd68ac3360a819931cb0553d77f17fa52e694b..b137dd001375285c2781fc57a45b0e90cc838ea4 100644 (file)
@@ -1139,7 +1139,7 @@ void slapi_connection_set_pb( Slapi_PBlock *pb, Connection *conn )
        char *connAuthType;
        size_t len;
 
-       slapi_pblock_set(pb, SLAPI_CONNECTION, conn);
+       slapi_pblock_set(pb, SLAPI_CONNECTION, (void *)conn);
        slapi_pblock_set(pb, SLAPI_CONN_ID, (void *)conn->c_connid);
        switch (conn->c_authz.sai_method) {
        case LDAP_AUTH_SASL: 
@@ -1161,14 +1161,42 @@ void slapi_connection_set_pb( Slapi_PBlock *pb, Connection *conn )
                connAuthType = slapi_ch_strdup(SLAPD_AUTH_SSL);
        }
        if (connAuthType != NULL) {
-               slapi_pblock_set(pb, SLAPI_CONN_AUTHTYPE, connAuthType);
+               slapi_pblock_set(pb, SLAPI_CONN_AUTHTYPE, (void *)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));
+               char *connDn = slapi_ch_strdup(conn->c_authz.sai_dn.bv_val);
+               slapi_pblock_set(pb, SLAPI_CONN_DN, (void *)connDn);
        }
 #endif /* defined(LDAP_SLAPI) */
 }
 
+/*
+ * Internal API to prime a Slapi_PBlock with an Operation.
+ */
+void slapi_operation_set_pb( Slapi_PBlock *pb, Operation *op )
+{
+#if defined(LDAP_SLAPI)
+       int isRoot = 0;
+       int isUpdateDn = 0;
+       Backend *be;
+
+       if (slapi_pblock_get(pb, SLAPI_BACKEND, (void *)&be) != 0) {
+               be = NULL;
+       }
+       if (be != NULL) {
+               isRoot = be_isroot(be, &op->o_ndn);
+               isUpdateDn = be_isupdate(be, &op->o_ndn);
+       }
+               
+       slapi_pblock_set(pb, SLAPI_OPERATION, (void *)op);
+       slapi_pblock_set(pb, SLAPI_OPINITIATED_TIME, (void *)op->o_time);
+       slapi_pblock_set(pb, SLAPI_REQUESTOR_ISROOT, (void *)isRoot);
+       slapi_pblock_set(pb, SLAPI_REQUESTOR_ISUPDATEDN, (void *)isUpdateDn);
+       slapi_pblock_set(pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls);
+       slapi_pblock_set(pb, SLAPI_REQUESTOR_DN, (void *)op->o_ndn.bv_val);
+#endif
+}
+
 int slapi_is_connection_ssl( Slapi_PBlock *pb, int *isSSL )
 {
 #if defined( LDAP_SLAPI )
index 9820eab2c5e3860ee2b62f771bf77a044da80de1..184dd9e3ac1dc2f93f7ef8466dd135f228b1298a 100644 (file)
@@ -107,7 +107,9 @@ 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 );
+void slapi_operation_set_pb( Slapi_PBlock *pb, Operation *op );
 
 extern ldap_pvt_thread_mutex_t slapi_hn_mutex;
 extern ldap_pvt_thread_mutex_t slapi_time_mutex;