Groups

Working with Groups

Foldr Groups are also available in MaSH including those from Active Directory/LDAP.

LDAP Groups hosted within the Active Directory which is connected to Foldr. These group objects are read-only but can be added as members of Local Foldr groups.

Local Groups within the Foldr appliance. These groups are read/write and can be created, updated and deleted by MaSH.

Retrieving Specific Groups

get

mash.groups.get(string: identifier, string: ?type) -> Collection|Group

Retrieves a user single group object or a Collection of groups which match the identifier and type provided.

Parameters

identifier

Group names cannot be considered unique within Foldr since it is possible that LDAP groups and Local groups could have the same name. Providing a name here will return a collection of groups unless a value is also provided for the type parameter.

If you provide a GUID as the identifier then this method will return a single Group object.

type (optional)

Either ldap or local.

Natural

# This will retrieve a single user using their GUID
set myGroup to mash.groups.get("550eca96-4837-4ec8-817c-11670e88dcda")

printline myGroup

# Since it's possible that an external user may have the same username as an LDAP user, this will return a collection of Users
set myGroups to mash.users.get("My Group")

printline(myGroups)

Standard

# This will retrieve a single user using their GUID
myGroup = mash.groups.get("550eca96-4837-4ec8-817c-11670e88dcda")

printline(myGroup)

# Since it's possible that an external user may have the same username as an LDAP user, this will return a collection of Users
myGroups = mash.users.get("My Group")

printline(myGroups)

Output

Group {
	"guid": "bd610b5c-75ed-485c-81df-47621519b410",
	"type": "ldap",
	"name": "My Group",
	"last_updated": "2022-02-06T11:42:38+00:00"
}

Collection [
	{
	  "guid": "bd610b5c-75ed-485c-81df-47621519b410",
	  "type": "ldap",
	  "name": "My Group",
	  "last_updated": "2022-02-06T11:42:38+00:00"
	},
	{
	  "guid": "367bd02a-835b-41b9-b4a7-5c8c43481fd8",
	  "type": "local",
	  "name": "My Group",
	  "last_updated": "2022-01-10T09:00:00+00:00"
	}
]

Notes

This method can also be called via the shorthand form:

mash.group(string: identifier, string: ?type) -> Group

When the shorthand form is used it will only ever return a single group object. If a group name is provided as the identifier then the first matching group will be returned.


Retrieving All Groups

all

mash.groups.all(boolean: ?sync = false) -> Collection

Retrieves all groups.

Parameters

sync

If this is false only Active Directory groups previously seen by Foldr will be returned alongside any local groups. If set to true MaSH will query the Active Directory directly for ldap groups to return.


Creating Groups

make

mash.groups.make(dictionary: ?properties) -> Group

Create a new Group object. Creating ldap groups is not currently supported.

Parameters

properties

A dictionary containing key/value combinations for the various properties to be set on the group. A random GUID will be generated for the new Group.

Notes

When creating a new Group object it will not be persisted until the update() method is called. This allows you to set the Group’s properties before saving it.

Natural

set myGroup to mash.groups.make({name: "My New Group"})

printline myGroup

# Note that the group will not be persisted until you call its update() method

Standard

myGroup = mash.groups.make({name: "My New Group"})

printline(myGroup)

# Note that the user will not be persisted until you call its update() method

Output

Group {
	"guid": "515b2225-873d-4d34-ad9d-fface002935b",
	"type": "local",
	"name": "My New Group"
}

The Group Object

Properties

name

name: string  get/set

The name of the group.

Notes

This attribute must be unique for each type of group (ldap, local).

For Active Directory groups this is read-only.

guid

guid: string  get

The unique identifier for each group.

lastUpdated

lastUpdated: date  get

The date that the group was last changed.

Methods

addMembers

addMembers(array<User|Group>|User|Group: ?members)

Add users or other groups as members of a group.

Parameters

members

An array or collection of users and groups or a single User or Group

Natural

set myUser to mash.users.get("b8236683-6426-4658-bf6f-0e78068ca327")

set myGroup to mash.groups.get("550eca96-4837-4ec8-817c-11670e88dcda")

myGroup.addMembers(myUser)

Standard

myUser = mash.users.get("b8236683-6426-4658-bf6f-0e78068ca327")

myGroup = mash.groups.get("550eca96-4837-4ec8-817c-11670e88dcda")

myGroup.addMembers(myUser)

removeMembers

removeMembers(array<User|Group>|User|Group: ?members)

Remove users or other groups as members of a group.

Parameters

members

An array or collection of users and groups or a single User or Group

Natural

set myUser to mash.users.get("b8236683-6426-4658-bf6f-0e78068ca327")

set myGroup to mash.groups.get("550eca96-4837-4ec8-817c-11670e88dcda")

myGroup.removeMembers(myUser)

Standard

myUser = mash.users.get("b8236683-6426-4658-bf6f-0e78068ca327")

myGroup = mash.groups.get("550eca96-4837-4ec8-817c-11670e88dcda")

myGroup.removeMembers(myUser)

← All articles