private void SaveRole() { BindingSource bindingSource = grid.DataSource as BindingSource; BindingList <Privilege> privileges = bindingSource.DataSource as BindingList <Privilege>; string name = nameBox.Text.Trim(); string[] whitelistArray = whiteListBox.Text.Trim().Split(','); List <string> whitelist = new List <string>(whitelistArray.Length); foreach (string wl in whitelistArray) { string s = wl.Trim(); if (s.Length > 0) { whitelist.Add(s); } } switch (editType) { case EditType.CREATE: if (privileges.Count == 0 && whitelist.Count == 0) { throw new AerospikeException("Privileges or whitelist is required."); } client.CreateRole(null, name, privileges, whitelist); break; case EditType.EDIT: ReplacePrivileges(name, privileges); ReplaceWhitelist(name, whitelist); break; } }
private void SaveRole() { BindingSource bindingSource = grid.DataSource as BindingSource; BindingList <Privilege> privileges = bindingSource.DataSource as BindingList <Privilege>; string name = nameBox.Text.Trim(); switch (editType) { case EditType.CREATE: if (privileges.Count == 0) { throw new AerospikeException("No privileges were created."); } client.CreateRole(null, name, privileges); break; case EditType.EDIT: ReplacePrivileges(name, privileges); break; } }
public void createRole() { Console.WriteLine("\n********** Create Role **********\n"); int privilegeCode; string role; // Get username Console.WriteLine("Enter role: "); role = Console.ReadLine(); if (role != null && role.Length > 0) { // Add privilege Console.WriteLine("Enter a privilege code\n(0 = read, 1 = read-write, 2 = read-write-udf, 4 = sys-admin, 5 = user-admin):"); privilegeCode = int.Parse(Console.ReadLine()); Privilege privilege = new Privilege(); switch (privilegeCode) { case 0: privilege.code = PrivilegeCode.READ; break; case 1: privilege.code = PrivilegeCode.READ_WRITE; break; case 2: privilege.code = PrivilegeCode.READ_WRITE_UDF; break; //MISSING FROM API! case 3: privilege.code = PrivilegeCode.DATA_ADMIN; break; case 4: privilege.code = PrivilegeCode.SYS_ADMIN; break; case 5: privilege.code = PrivilegeCode.USER_ADMIN; break; } // Create role AdminPolicy adminPolicy = new AdminPolicy(); Privilege[] privileges = { privilege }; client.CreateRole(adminPolicy, role, privileges); Console.WriteLine("\nINFO: Role created!"); } }