forked from demisto/content
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript-ActiveUsersD2.yml
More file actions
48 lines (44 loc) · 1.42 KB
/
Copy pathscript-ActiveUsersD2.yml
File metadata and controls
48 lines (44 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
commonfields:
id: ActiveUsersD2
version: -1
name: ActiveUsersD2
script: |-
resp = executeCommand("D2ActiveUsers", {});
if (isError(resp[0])) {
return resp;
}
data = dq(resp[0],'Contents');
if (!data) {
return { ContentsFormat: formats.text, Type: entryTypes.error, Contents: 'No Active Users were found' };
}
users = [];
data.forEach(function(u){
var user = {};
var username = null;
var domain = null;
user = dq(u,"Antecedent");
user = user.split(",");
if (user.length === 2) {
try {
domain = user[0].split('=')[1].replace(/['"]+/g, '')
username = user[1].split('=')[1].replace(/['"]+/g, '')
} catch (ex) {
return ex;
}
}
if(domain && username) {
users.push({'Username' : username, 'Domain' : domain});
}
});
users = uniqBy(users, JSON.stringify);
var res = users;
var md = tableToMarkdown("Users", users);
var ec = {"Account(val.Username == obj.Username)" : users};
return ( {'ContentsFormat': formats.json, 'Type': entryTypes.note, 'Contents': res, "HumanReadable": md, "EntryContext": ec} );
type: javascript
tags:
- endpoint
- agent
comment: Get active users from a D2 agent and parsed them into context
system: true
scripttarget: 0