-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from D00MFist/master
Updates for macOS Monterey (12.0) and small doc updates
- Loading branch information
Showing
10 changed files
with
89 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,71 @@ | ||
exports.list_users = function(task, command, params){ | ||
let all_users = []; | ||
let gid = -1; | ||
let groups = false; | ||
if(params.length > 0){ | ||
let data = JSON.parse(params); | ||
if(data.hasOwnProperty('gid') && data['gid'] !== "" && data['gid'] > 0){ | ||
var all_users = []; | ||
var gid = -1; | ||
if (params.length > 0) { | ||
var data = JSON.parse(params); | ||
if (data.hasOwnProperty('gid') && data['gid'] !== "" && data['gid'] > 0) { | ||
gid = data['gid']; | ||
} | ||
if(data.hasOwnProperty("groups") && data['groups'] !== ""){ | ||
groups = data['groups']; | ||
} | ||
} | ||
} | ||
ObjC.import('Collaboration'); | ||
ObjC.import('CoreServices'); | ||
if(gid < 0){ | ||
let defaultAuthority = $.CSGetLocalIdentityAuthority(); | ||
let identityClass = 2; | ||
if(groups){ | ||
all_users = []; // we will want to do a dictionary so we can group the members by their GID | ||
} | ||
else{ | ||
identityClass = 1; //enumerate users | ||
} | ||
let query = $.CSIdentityQueryCreate($(), identityClass, defaultAuthority); | ||
let error = Ref(); | ||
$.CSIdentityQueryExecute(query, 0, error); | ||
let results = $.CSIdentityQueryCopyResults(query); | ||
let numResults = parseInt($.CFArrayGetCount(results)); | ||
if(results.js === undefined){ | ||
results = $.CFMakeCollectable(results); | ||
} | ||
for(let i = 0; i < numResults; i++){ | ||
let identity = results.objectAtIndex(i);//results[i]; | ||
let idObj = $.CBIdentity.identityWithCSIdentity(identity); | ||
if(groups){ | ||
//if we're looking at groups, then we have a different info to print out | ||
all_users[i] = {}; | ||
all_users[i]["POSIXID"] = idObj.posixGID; | ||
all_users[i]['aliases'] = ObjC.deepUnwrap(idObj.aliases); | ||
all_users[i]['fullName'] = ObjC.deepUnwrap(idObj.fullName); | ||
all_users[i]['POSIXName'] = ObjC.deepUnwrap(idObj.posixName); | ||
all_users[i]['members'] = []; | ||
let members = idObj.memberIdentities.js; | ||
for(let j = 0; j < members.length; j++){ | ||
let info = { | ||
"POSIXName": members[j].posixName.js, | ||
"POSIXID": members[j].posixUID, | ||
"LocalAuthority": members[j].authority.localizedName.js, | ||
"FullName": members[j].fullName.js, | ||
"Emails": members[j].emailAddress.js, | ||
"isHiddenAccount": members[j].isHidden, | ||
"Enabled": members[j].isEnabled, | ||
"Aliases": ObjC.deepUnwrap(members[j].aliases), | ||
"UUID": members[j].UUIDString.js | ||
}; | ||
all_users[i]['members'].push(info); | ||
} | ||
} | ||
else{ | ||
let info = { | ||
if (gid < 0) { | ||
var defaultAuthority = $.CBIdentityAuthority.defaultIdentityAuthority; | ||
var grouptolook = 1000 //Most systems don't have groups past 700s | ||
for (var x = 0; x < grouptolook; x++) { | ||
var group = $.CBGroupIdentity.groupIdentityWithPosixGIDAuthority(x, defaultAuthority); | ||
validGroupcheck = group.toString() | ||
if (validGroupcheck == "[id CBGroupIdentity]") { | ||
var results = group.memberIdentities.js; | ||
|
||
var numResults = results.length; | ||
for (var i = 0; i < numResults; i++) { | ||
var idObj = results[i]; | ||
var info = { | ||
"POSIXName": idObj.posixName.js, | ||
"POSIXID": idObj.posixUID, | ||
"POSIXID": idObj.posixUID, | ||
"POSIXGID": group.posixGID, | ||
"LocalAuthority": idObj.authority.localizedName.js, | ||
"FullName": idObj.fullName.js, | ||
"Emails": idObj.emailAddress.js, | ||
"Emails": idObj.emailAddress.js, | ||
"isHiddenAccount": idObj.isHidden, | ||
"Enabled": idObj.isEnabled, | ||
"Aliases": ObjC.deepUnwrap(idObj.aliases), | ||
"UUID": idObj.UUIDString.js | ||
}; | ||
all_users.push(info); | ||
all_users.push(info); | ||
} | ||
|
||
} | ||
} | ||
} | ||
else{ | ||
let defaultAuthority = $.CBIdentityAuthority.defaultIdentityAuthority; | ||
let group = $.CBGroupIdentity.groupIdentityWithPosixGIDAuthority(gid, defaultAuthority); | ||
let results = group.memberIdentities.js; | ||
let numResults = results.length; | ||
for(let i = 0; i < numResults; i++){ | ||
let idObj = results[i]; | ||
let info = { | ||
"POSIXName": idObj.posixName.js, | ||
"POSIXID": idObj.posixUID, | ||
"LocalAuthority": idObj.authority.localizedName.js, | ||
"FullName": idObj.fullName.js, | ||
"Emails": idObj.emailAddress.js, | ||
"isHiddenAccount": idObj.isHidden, | ||
"Enabled": idObj.isEnabled, | ||
"Aliases": ObjC.deepUnwrap(idObj.aliases), | ||
"UUID": idObj.UUIDString.js | ||
}; | ||
return { | ||
"user_output": JSON.stringify(all_users, null, 2), | ||
"completed": true | ||
} | ||
} else { | ||
var defaultAuthority = $.CBIdentityAuthority.defaultIdentityAuthority; | ||
var group = $.CBGroupIdentity.groupIdentityWithPosixGIDAuthority(gid, defaultAuthority); | ||
var results = group.memberIdentities.js; | ||
var numResults = results.length; | ||
for (var i = 0; i < numResults; i++) { | ||
var idObj = results[i]; | ||
var info = { | ||
"POSIXName": idObj.posixName.js, | ||
"POSIXID": idObj.posixUID, | ||
"POSIXGID": group.posixGID, | ||
"LocalAuthority": idObj.authority.localizedName.js, | ||
"FullName": idObj.fullName.js, | ||
"Emails": idObj.emailAddress.js, | ||
"isHiddenAccount": idObj.isHidden, | ||
"Enabled": idObj.isEnabled, | ||
"Aliases": ObjC.deepUnwrap(idObj.aliases), | ||
"UUID": idObj.UUIDString.js | ||
}; | ||
all_users.push(info); | ||
} | ||
} | ||
return {"user_output":JSON.stringify(all_users, null, 2), "completed": true}; | ||
return { | ||
"user_output": JSON.stringify(all_users, null, 2), | ||
"completed": true | ||
}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters