--- /dev/null
+/*
+ Unix SMB/CIFS implementation.
+
+ idmap SAMBA4 backend
+
+ Copyright (C) Simo Sorce 2006
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "s3compat/s3compat_authenticate.h"
+#include "../winbind/idmap.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_IDMAP
+
+/*****************************
+ Initialise idmap database.
+*****************************/
+
+static NTSTATUS idmap_samba4_backend_init(struct idmap_domain *dom, const char *params)
+{
+ dom->private_data = s3compat_idmap_init(dom);
+ if (!dom->private_data) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ return NT_STATUS_OK;
+}
+
+/**********************************
+ lookup a set of unix ids.
+**********************************/
+
+static NTSTATUS idmap_samba4_unixids_to_sids(struct idmap_domain *dom, struct id_map **ids)
+{
+ struct idmap_context *idmap_ctx = talloc_get_type_abort(
+ dom->private_data, struct idmap_context);
+ NTSTATUS status;
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
+ status = idmap_xids_to_sids(idmap_ctx, tmp_ctx, ids);
+ talloc_free(tmp_ctx);
+ return status;
+}
+
+/**********************************
+ lookup a set of sids.
+**********************************/
+
+static NTSTATUS idmap_samba4_sids_to_unixids(struct idmap_domain *dom, struct id_map **ids)
+{
+ struct idmap_context *idmap_ctx = talloc_get_type_abort(
+ dom->private_data, struct idmap_context);
+ NTSTATUS status;
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
+ NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
+
+ status = idmap_sids_to_xids(idmap_ctx, tmp_ctx, ids);
+ talloc_free(tmp_ctx);
+ return status;
+}
+
+/**********************************
+ Close the idmap samba4 instance
+**********************************/
+
+static NTSTATUS idmap_samba4_close(struct idmap_domain *dom)
+{
+ talloc_free(dom->private_data);
+ return NT_STATUS_OK;
+}
+
+static struct idmap_methods samba4_methods = {
+ .init = idmap_samba4_backend_init,
+ .unixids_to_sids = idmap_samba4_unixids_to_sids,
+ .sids_to_unixids = idmap_samba4_sids_to_unixids,
+ .close_fn =idmap_samba4_close
+};
+
+NTSTATUS idmap_samba4_init(void)
+{
+ return smb_register_idmap(SMB_IDMAP_INTERFACE_VERSION, "samba4", &samba4_methods);
+}