return NULL;
}
+/*
+ * register a principal for an auth_type
+ *
+ * In order to get used in dcesrv_mgmt_inq_princ_name()
+ */
+_PUBLIC_ NTSTATUS dcesrv_auth_type_principal_register(struct dcesrv_context *dce_ctx,
+ enum dcerpc_AuthType auth_type,
+ const char *principal_name)
+{
+ const char *existing = NULL;
+ struct dcesrv_ctx_principal *p = NULL;
+
+ existing = dcesrv_auth_type_principal_find(dce_ctx, auth_type);
+ if (existing != NULL) {
+ DBG_ERR("auth_type[%u] already registered with principal_name[%s]\n",
+ auth_type, existing);
+ return NT_STATUS_ALREADY_REGISTERED;
+ }
+
+ p = talloc_zero(dce_ctx, struct dcesrv_ctx_principal);
+ if (p == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ p->auth_type = auth_type;
+ p->principal_name = talloc_strdup(p, principal_name);
+ if (p->principal_name == NULL) {
+ TALLOC_FREE(p);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ DLIST_ADD_END(dce_ctx->principal_list, p);
+ return NT_STATUS_OK;
+}
+
+_PUBLIC_ const char *dcesrv_auth_type_principal_find(struct dcesrv_context *dce_ctx,
+ enum dcerpc_AuthType auth_type)
+{
+ struct dcesrv_ctx_principal *p = NULL;
+
+ for (p = dce_ctx->principal_list; p != NULL; p = p->next) {
+ if (p->auth_type == auth_type) {
+ return p->principal_name;
+ }
+ }
+
+ return NULL;
+}
+
/*
register an interface on an endpoint
bool use_single_process;
} *endpoint_list;
+ /*
+ * registered auth_type/principals
+ * for dcesrv_mgmt_inq_princ_name()
+ */
+ struct dcesrv_ctx_principal {
+ struct dcesrv_ctx_principal *next, *prev;
+ enum dcerpc_AuthType auth_type;
+ const char *principal_name;
+ } *principal_list;
+
/* loadparm context to use for this connection */
struct loadparm_context *lp_ctx;
int sizeof_dcesrv_handle;
};
+NTSTATUS dcesrv_auth_type_principal_register(struct dcesrv_context *dce_ctx,
+ enum dcerpc_AuthType auth_type,
+ const char *principal_name);
+const char *dcesrv_auth_type_principal_find(struct dcesrv_context *dce_ctx,
+ enum dcerpc_AuthType auth_type);
NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
const char *ep_name,
const char *ncacn_np_secondary_endpoint,
static WERROR dcesrv_mgmt_inq_princ_name(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
struct mgmt_inq_princ_name *r)
{
- DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+ const char *principal = NULL;
+
+ if (r->in.princ_name_size < 1) {
+ DCESRV_FAULT(DCERPC_FAULT_BAD_STUB_DATA);
+ }
+
+ r->out.princ_name = "";
+
+ principal = dcesrv_auth_type_principal_find(dce_call->conn->dce_ctx,
+ r->in.authn_proto);
+ if (principal == NULL) {
+ return WERR_RPC_S_UNKNOWN_AUTHN_SERVICE;
+ }
+
+ if (strlen(principal) + 1 > r->in.princ_name_size) {
+ return WERR_INSUFFICIENT_BUFFER;
+ }
+
+ r->out.princ_name = principal;
+ return WERR_OK;
}