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 2 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, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include "lib/appweb/ejs/ejs.h"
26 #include "libnet/libnet.h"
27 #include "scripting/ejs/smbcalls.h"
28 #include "events/events.h"
29 #include "auth/credentials/credentials.h"
34 DomainsList.Domains[0]
37 struct MprVar mprDomainsList(TALLOC_CTX *mem_ctx, struct libnet_DomainList *list, NTSTATUS result)
39 const char *name = "DomainsList";
41 struct MprVar mprDomainList, mprDomains;
42 struct MprVar mprSid, mprDomainName;
43 struct MprVar mprDomain;
46 if (list == NULL || mem_ctx == NULL) {
47 mprDomainList = mprCreateNullVar();
51 mprDomains = mprArray("Domains");
52 for (i = 0; i < list->out.count; i++) {
53 struct domainlist d = list->out.domains[i];
55 /* get domainlist fields */
56 mprSid = mprString(d.sid);
57 mprDomainName = mprString(d.name);
59 mprDomain = mprObject("Domain");
60 mprSetVar(&mprDomain, "Name", mprDomainName);
61 mprSetVar(&mprDomain, "SID", mprSid);
63 mprAddArray(&mprDomains, i, mprDomain);
66 mprDomainList = mprObject(name);
67 status = mprSetVar(&mprDomainList, "Domains", mprDomains);
68 if (!NT_STATUS_IS_OK(status)) goto done;
69 status = mprSetVar(&mprDomainList, "Count", mprCreateIntegerVar(list->out.count));
70 if (!NT_STATUS_IS_OK(status)) goto done;
71 status = mprSetVar(&mprDomainList, "Status", mprNTSTATUS(result));