forked from pbowden-msft/ExtensionAttributes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOffice365_Logons.xml
39 lines (32 loc) · 1.15 KB
/
Office365_Logons.xml
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
<?xml version="1.0" encoding="UTF-8"?><extensionAttribute>
<displayName>Office 365 Active Logons</displayName>
<description/>
<dataType>string</dataType>
<scriptContentsMac>#!/bin/sh
# Functions
function DetectO365Logon {
# creates a list of local usernames with UIDs above 500 (not hidden)
userList=$( /usr/bin/dscl /Local/Default -list /Users uid | /usr/bin/awk '$2 >= 501 { print $1 }' )
while IFS= read aUser
do
# get the user's home folder path
HOMEPATH=$( eval /bin/echo ~$aUser )
# execute some sql to get the active O365 logon, if any
local RESULT=$(/usr/bin/sqlite3 "$HOMEPATH/Library/Group Containers/UBF8T346G9.Office/MicrosoftRegistrationDB.reg" "SELECT value from HKEY_CURRENT_USER_values WHERE name='UserDisplayName' LIMIT 1;")
# checks to see if we got a hit
if [ "$RESULT" != "" ]; then
logons+="$RESULT;"
fi
done <<< "$userList"
/bin/echo "$logons"
}
## Main
O365LOGONS=$(DetectO365Logon)
if [ "$O365LOGONS" != "" ]; then
/bin/echo "<result>$O365LOGONS</result>"
else
/bin/echo "<result>None detected</result>"
fi
exit 0</scriptContentsMac>
<scriptContentsWindows/>
</extensionAttribute>