Skip to main content

New

C#
1
2
3
public Role New(LocalizedString name, LocalizedString description = null) { }

Remarks

Example

C#
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
using Zengenti.Contensis.Management; var client = ManagementClient.Create(); // Access the movie DB project. var project = client.Projects.Get("movieDb"); // Create the role. var newRole = project.Security.Roles.New("Movie author", "Movie authors can create and update movie related content"); // Assign the required permissions to be able to create and update a movie and actor entries. newRole.Permissions.Entries.Add( new EntryPermission("movie", new List<string> { "contensisEntryBasic.sysCreate", "contensisEntryBasic.draft.sysUpdate" })); newRole.Permissions.Entries.Add( new EntryPermission("actor", new List<string> { "contensisEntryBasic.sysCreate", "contensisEntryBasic.draft.sysUpdate" })); // Assign users to the role. newRole.Assignments.Users.Add("m.jackson"); newRole.Assignments.Users.Add("g.michael"); try { // Save the role to take effect. await newRole.SaveAsync(); } catch(RestRequestException restEx) { // Handle service error. } catch(ValidationException valEx) { // Handle data validation errors. } catch(Exception ex) { // Handle anything else, e.g. network error. }

Still need help?

New support request