summaryrefslogtreecommitdiff
path: root/source4/scripting/ejs/ejsnet/mpr_host.c
diff options
context:
space:
mode:
authorRafal Szczesniak <mimir@samba.org>2007-05-24 21:44:27 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:52:51 -0500
commit9bd9acae1cdd0475235d5e8960a9a0d8d40de008 (patch)
treec9ca88cdc7c104a87f42fba273306069ef7a50eb /source4/scripting/ejs/ejsnet/mpr_host.c
parent4fa973e4a48f6f4de4c8937d6c2472564b760c76 (diff)
downloadsamba-9bd9acae1cdd0475235d5e8960a9a0d8d40de008.tar.gz
samba-9bd9acae1cdd0475235d5e8960a9a0d8d40de008.tar.bz2
samba-9bd9acae1cdd0475235d5e8960a9a0d8d40de008.zip
r23124: add host subcontext providing (at the moment) list of domains
hosted on the server. rafal (This used to be commit 385a094443e29990a2895693f2b6435e3d32c0f3)
Diffstat (limited to 'source4/scripting/ejs/ejsnet/mpr_host.c')
-rw-r--r--source4/scripting/ejs/ejsnet/mpr_host.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/source4/scripting/ejs/ejsnet/mpr_host.c b/source4/scripting/ejs/ejsnet/mpr_host.c
new file mode 100644
index 0000000000..1755b23085
--- /dev/null
+++ b/source4/scripting/ejs/ejsnet/mpr_host.c
@@ -0,0 +1,75 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ provides interfaces to libnet calls from ejs scripts
+
+ Copyright (C) Rafal Szczesniak 2005-2007
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+
+#include "includes.h"
+#include "lib/appweb/ejs/ejs.h"
+#include "libnet/libnet.h"
+#include "scripting/ejs/smbcalls.h"
+#include "events/events.h"
+#include "auth/credentials/credentials.h"
+
+
+/*
+ Properties:
+ DomainsList.Domains[0]
+ DomainsList.Status
+*/
+struct MprVar mprDomainsList(TALLOC_CTX *mem_ctx, struct libnet_DomainList *list, NTSTATUS result)
+{
+ const char *name = "DomainsList";
+ NTSTATUS status;
+ struct MprVar mprDomainList, mprDomains;
+ struct MprVar mprSid, mprDomainName;
+ struct MprVar mprDomain;
+ int i;
+
+ if (list == NULL || mem_ctx == NULL) {
+ mprDomainList = mprCreateNullVar();
+ goto done;
+ }
+
+ mprDomains = mprArray("Domains");
+ for (i = 0; i < list->out.count; i++) {
+ struct domainlist d = list->out.domains[i];
+
+ /* get domainlist fields */
+ mprSid = mprString(d.sid);
+ mprDomainName = mprString(d.name);
+
+ mprDomain = mprObject("Domain");
+ mprSetVar(&mprDomain, "Name", mprDomainName);
+ mprSetVar(&mprDomain, "SID", mprSid);
+
+ mprAddArray(&mprDomains, i, mprDomain);
+ }
+
+ mprDomainList = mprObject(name);
+ status = mprSetVar(&mprDomainList, "Domains", mprDomains);
+ if (!NT_STATUS_IS_OK(status)) goto done;
+ status = mprSetVar(&mprDomainList, "Count", mprCreateIntegerVar(list->out.count));
+ if (!NT_STATUS_IS_OK(status)) goto done;
+ status = mprSetVar(&mprDomainList, "Status", mprNTSTATUS(result));
+
+done:
+ return mprDomainList;
+}