protected TSimpleViewModel GetViewModel(int?id, GlobalEnums.AccessLevel accessLevel, bool forDelete, bool forAlter, bool forOpen) { TEntity entity = this.GetEntityAndCheckAccessLevel(id, accessLevel); if (entity == null) { return(null); } return(this.BuildViewModel(entity, forDelete, forAlter, forOpen)); }
protected virtual TEntity GetEntityAndCheckAccessLevel(int?id, GlobalEnums.AccessLevel accessLevel) { TEntity entity; if (id == null || (entity = this.GenericService.GetByID((int)id)) == null) { return(null); } if (this.GenericService.GetAccessLevel(entity.OrganizationalUnitID) < accessLevel) { return(null); } return(entity); }
protected TSimpleViewModel GetViewModel(int?id, GlobalEnums.AccessLevel accessLevel, bool forDelete, bool forAlter) { return(this.GetViewModel(id, accessLevel, forDelete, forAlter, false)); }
/// <summary> /// There are serveral times have to build ViewModel from Entity, by the same steps /// This is the reason to have GetViewModel. This is not for any purpose. This GetViewModel may change or ormit if needed /// </summary> /// <param name="entity"></param> /// <returns></returns> protected TSimpleViewModel GetViewModel(int?id, GlobalEnums.AccessLevel accessLevel) { return(this.GetViewModel(id, accessLevel, false)); }
public AccessLevelAuthorizeAttribute(GlobalEnums.AccessLevel accessLevel) { this.accessLevel = accessLevel; }
protected virtual bool AccessLevelAuthorize(GlobalEnums.AccessLevel accessLevel) { return(this.BaseService.GetAccessLevel() >= accessLevel); }
public UserRegister(UserAPIs userAPIs, OrganizationalUnitAPIs organizationalUnitAPIs) { InitializeComponent(); try { List <DomainUser> allUsers = new List <DomainUser>(); //userAPIs.UpdateUserName("S-1-5-21-3775195119-1044016383-3360809325-1001", "NMVN\vendor"); if (true) { PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "chevronvn.com"); //, "OU=SomeOU,dc=YourCompany,dc=com"// create your domain context and define the OU container to search in UserPrincipal qbeUser = new UserPrincipal(ctx); // define a "query-by-example" principal - here, we search for a UserPrincipal (user) PrincipalSearcher srch = new PrincipalSearcher(qbeUser); // create your principal searcher passing in the QBE principal foreach (var found in srch.FindAll()) // find all matches { // do whatever here - "found" is of type "Principal" - it could be user, group, computer..... if (found.Sid.Value != null && found.Sid.Value != "" && found.SamAccountName != null && found.SamAccountName != "") { userAPIs.UpdateUserName(found.Sid.Value, found.SamAccountName); } allUsers.Add(new DomainUser() { FirstName = "", LastName = "", UserName = found.SamAccountName, SecurityIdentifier = found.Sid.Value }); //found.UserPrincipalName: the same as SamAccountName, but with @chevron.com } } else { for (int i = 1; i <= 5; i++) { allUsers.Add(new DomainUser() { FirstName = "FIST NAME" + i.ToString(), LastName = "FIST NAME" + i.ToString(), UserName = "******", SecurityIdentifier = "S-1-5-21-2907738014-1953812902-1740135539-2131" }); } } this.combexUserID.DataSource = allUsers; this.combexUserID.DisplayMember = CommonExpressions.PropertyName <DomainUser>(p => p.UserName); this.combexUserID.ValueMember = CommonExpressions.PropertyName <DomainUser>(p => p.UserName); this.bindingUserName = this.combexUserID.DataBindings.Add("SelectedValue", this, CommonExpressions.PropertyName <DomainUser>(p => p.UserName), true, DataSourceUpdateMode.OnPropertyChanged); this.bindingUserName.BindingComplete += binding_BindingComplete; this.userAPIs = userAPIs; this.organizationalUnitAPIs = organizationalUnitAPIs; this.combexOrganizationalUnitID.DataSource = this.organizationalUnitAPIs.GetOrganizationalUnitIndexes(); this.combexOrganizationalUnitID.DisplayMember = CommonExpressions.PropertyName <OrganizationalUnitIndex>(p => p.LocationOrganizationalUnitName); this.combexOrganizationalUnitID.ValueMember = CommonExpressions.PropertyName <OrganizationalUnitIndex>(p => p.OrganizationalUnitID); this.bindingOrganizationalUnitID = this.combexOrganizationalUnitID.DataBindings.Add("SelectedValue", this, CommonExpressions.PropertyName <OrganizationalUnitIndex>(p => p.OrganizationalUnitID), true, DataSourceUpdateMode.OnPropertyChanged); this.bindingOrganizationalUnitID.BindingComplete += binding_BindingComplete; this.SameOUAccessLevel = GlobalEnums.AccessLevel.NoAccess; this.combexSameOUAccessLevels.DataSource = new List <ACL>() { new ACL() { AccessLevelID = GlobalEnums.AccessLevel.NoAccess }, new ACL() { AccessLevelID = GlobalEnums.AccessLevel.Readable }, new ACL() { AccessLevelID = GlobalEnums.AccessLevel.Editable } }; this.combexSameOUAccessLevels.DisplayMember = CommonExpressions.PropertyName <ACL>(p => p.AccessLevelName); this.combexSameOUAccessLevels.ValueMember = CommonExpressions.PropertyName <ACL>(p => p.AccessLevelID); this.combexSameOUAccessLevels.DataBindings.Add("SelectedValue", this, "SameOUAccessLevel", true, DataSourceUpdateMode.OnPropertyChanged); this.SameLocationAccessLevel = GlobalEnums.AccessLevel.NoAccess; this.combexSameLocationAccessLevels.DataSource = new List <ACL>() { new ACL() { AccessLevelID = GlobalEnums.AccessLevel.NoAccess }, new ACL() { AccessLevelID = GlobalEnums.AccessLevel.Readable }, new ACL() { AccessLevelID = GlobalEnums.AccessLevel.Editable } }; this.combexSameLocationAccessLevels.DisplayMember = CommonExpressions.PropertyName <ACL>(p => p.AccessLevelName); this.combexSameLocationAccessLevels.ValueMember = CommonExpressions.PropertyName <ACL>(p => p.AccessLevelID); this.combexSameLocationAccessLevels.DataBindings.Add("SelectedValue", this, "SameLocationAccessLevel", true, DataSourceUpdateMode.OnPropertyChanged); this.OtherOUAccessLevel = GlobalEnums.AccessLevel.NoAccess; this.combexOtherOUAccessLevels.DataSource = new List <ACL>() { new ACL() { AccessLevelID = GlobalEnums.AccessLevel.NoAccess }, new ACL() { AccessLevelID = GlobalEnums.AccessLevel.Readable } }; this.combexOtherOUAccessLevels.DisplayMember = CommonExpressions.PropertyName <ACL>(p => p.AccessLevelName); this.combexOtherOUAccessLevels.ValueMember = CommonExpressions.PropertyName <ACL>(p => p.AccessLevelID); this.combexOtherOUAccessLevels.DataBindings.Add("SelectedValue", this, "OtherOUAccessLevel", true, DataSourceUpdateMode.OnPropertyChanged); } catch (Exception exception) { ExceptionHandlers.ShowExceptionMessageBox(this, exception); } }