public void ShouldGrantPrivileges() { Privilege.GrantPrivileges(_identityName, new[] { "SeServiceLogonRight" }); var privileges = Privilege.GetPrivileges(_identityName); Assert.That(privileges, Is.Not.Null); Assert.That(privileges, Contains.Item("SeServiceLogonRight")); }
public void ShouldHandleNoPrivileges() { var privileges = Privilege.GetPrivileges(_identityName); Privilege.RevokePrivileges(_identityName, privileges); privileges = Privilege.GetPrivileges(_identityName); Assert.That(privileges, Is.Not.Null); Assert.That(privileges.Length, Is.EqualTo(0)); }
public override object GetData() { var privilege = new Privilege(new PrivilegeBase()); return(privilege.GetPrivileges().Select(x => new { x.Id, Name = x.Description })); }
public void ShouldEnumerateLsaAccountRights() { Privilege.GetPrivileges(_identityName); }
public override object GetData() { var privilege = new Privilege(new PrivilegeBase()); return privilege.GetPrivileges().Select(x => new { x.Id, Name = x.Description }); }
/// <summary> /// Bind data to GridView /// </summary> private void BindDataToGridView() { #region clean privilege key of each cell //if exist rows of GridView if (dataRow != null && dataRow.Tables.Count > 0) { //Clean privilege key of each cell for (int i = 0; i < privilegeGridView.RowCount; i++) { for (int j = 4; j < privilegeGridView.ColumnCount; j = j + 3) { privilegeGridView.Rows[i].Cells[j].Value = null; } } } #endregion #region search data if (operationGroupKey != "" && resourceGroupKey != "") { #region create table for search DataSet dsGetPrivilege = new DataSet(); DataSet dataSet = new DataSet(); DataTable dataTable = CreateTableForSearchPrivilege(); //table for search Dictionary <string, string> rowData = new Dictionary <string, string>() { { "ROW_KEY", typeKey }, { RBAC_RESOURCE_GROUP_FIELDS.FIELD_RESOURCE_GROUP_KEY, resourceGroupKey }, { RBAC_OPERATION_GROUP_FIELDS.FIELD_OPERATION_GROUP_KEY, operationGroupKey }, { "TABLE_NAME", privilegeType } }; FanHai.Hemera.Utils.Common.Utils.AddRowDataToDataTable(ref dataTable, rowData); if (dataTable.Rows.Count > 0) { dataSet.Tables.Add(dataTable); } #endregion #region bind date to GridView privilegeEntity = new Privilege(); if (dataSet.Tables.Count > 0) { //get rights already assigned dsGetPrivilege = privilegeEntity.GetPrivileges(dataSet); if (privilegeEntity.ErrorMsg == "") { if (dsGetPrivilege.Tables[0].Rows.Count > 0) { for (int n = 0; n < dsGetPrivilege.Tables[0].Rows.Count; n++) { string resourceKey = dsGetPrivilege.Tables[0].Rows[n][RBAC_PRIVILEGE_FIELDS.FIELD_RESOURCE_KEY].ToString(); string operationKey = dsGetPrivilege.Tables[0].Rows[n][RBAC_PRIVILEGE_FIELDS.FIELD_OPERATION_KEY].ToString(); if (dataRow != null && dataRow.Tables.Count > 0) { //foreach row for (int i = 0; i < privilegeGridView.RowCount; i++) { //column 0 is resource key //column j is operation key //foreach column of operation key for (int j = 3; j < privilegeGridView.ColumnCount; j = j + 3) { int k = j - 1; //column of operation name int m = j + 1; //column of privilege key if (privilegeGridView.Rows[i].Cells[0].Value.ToString() == resourceKey && privilegeGridView.Rows[i].Cells[j].Value.ToString() == operationKey) { privilegeGridView.Rows[i].Cells[k].Value = "True"; privilegeGridView.Rows[i].Cells[m].Value = dsGetPrivilege.Tables[0].Rows[n][RBAC_PRIVILEGE_FIELDS.FIELD_PRIVILEGE_KEY].ToString(); } } } } } } } } #endregion } #endregion }