2 Unix SMB/CIFS implementation.
4 provides interfaces to libnet calls from ejs scripts
6 Copyright (C) Rafal Szczesniak 2005-2007
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "lib/appweb/ejs/ejs.h"
25 #include "libnet/libnet.h"
26 #include "scripting/ejs/smbcalls.h"
27 #include "events/events.h"
28 #include "auth/credentials/credentials.h"
33 DomainsList.Domains[0]
36 struct MprVar mprDomainsList(TALLOC_CTX *mem_ctx, struct libnet_DomainList *list, NTSTATUS result)
38 const char *name = "DomainsList";
40 struct MprVar mprDomainList, mprDomains;
41 struct MprVar mprSid, mprDomainName;
42 struct MprVar mprDomain;
45 if (list == NULL || mem_ctx == NULL) {
46 mprDomainList = mprCreateNullVar();
50 mprDomains = mprArray("Domains");
51 for (i = 0; i < list->out.count; i++) {
52 struct domainlist d = list->out.domains[i];
54 /* get domainlist fields */
55 mprSid = mprString(d.sid);
56 mprDomainName = mprString(d.name);
58 mprDomain = mprObject("Domain");
59 mprSetVar(&mprDomain, "Name", mprDomainName);
60 mprSetVar(&mprDomain, "SID", mprSid);
62 mprAddArray(&mprDomains, i, mprDomain);
65 mprDomainList = mprObject(name);
66 status = mprSetVar(&mprDomainList, "Domains", mprDomains);
67 if (!NT_STATUS_IS_OK(status)) goto done;
68 status = mprSetVar(&mprDomainList, "Count", mprCreateIntegerVar(list->out.count));
69 if (!NT_STATUS_IS_OK(status)) goto done;
70 status = mprSetVar(&mprDomainList, "Status", mprNTSTATUS(result));