public UserRights GetUserRightByUserId(int UserId) { UserRights userRights = new UserRights(null); try { string query = $"select * from dsto_userright where yref_user={UserId}"; var table = DbInfo.ExecuteSelectQuery(query); if (table.Rows.Count > 0) { foreach (DataRow row in table.Rows) { UserRight userRight = userRights.Add(); if (row["yref_configuration"] != DBNull.Value) { userRight.Configuration = new Configuration(); userRight.Configuration.OID = int.Parse(row["yref_configuration"].ToString()); } InitUserRight(userRight, row); } } } catch (Exception ex) { throw ex; } return(userRights); }
//获取用户列表 public static List <UserClass> LoadUserList() { string connString = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=""E:\c++练习\MyMoneyAgent - 副本 (2) - 副本\MyMoneyAgent\MyMoney.mdf"";Integrated Security=True"; SqlConnection conn = new SqlConnection(connString);//创建链接对象 try { conn.Open(); List <UserClass> userlist = new List <UserClass>(); string cmdTxt = "SELECT [姓名], [密码], [权限] FROM [用户]"; SqlCommand comm = new SqlCommand(cmdTxt, conn);//创建Commond的对象 SqlDataReader dr = comm.ExecuteReader(); while (dr.Read()) { string name = dr.GetString(0); string pwd = dr.GetString(1); UserRights rt = (UserRights)dr.GetInt32(2); UserClass user = new UserClass(name, pwd, rt); userlist.Add(user); } return(userlist); } catch (Exception) { return(null); } finally { conn.Close(); } }
public bool EnsureUserRights(int UserId) { var returnValue = false; try { using (var dbContext = new DatabaseContext()) { if (!dbContext.UserRights.Any(u => u.UserId == UserId)) { var rights = dbContext.RightsItems.ToList(); foreach (var item in rights) { var userRight = new UserRights(); userRight.UserId = UserId; userRight.RightsId = item.RightsId; userRight.Read = true; userRight.Write = true; userRight.CreatedDateTime = System.DateTime.Now; userRight.CreatedBy = 1; dbContext.UserRights.Add(userRight); } dbContext.SaveChanges(); } } } catch (Exception ex) { Helper.Helper.LogFile(ex, Server.MapPath("~/Error")); throw ex; } return(returnValue); }
private async Task UpdateUserRightClaiimsAsync(UserRights userRight, string projectName) { var principal = HttpContext.User; var list = new List <Claim>(); if (userRight.ChatChannelsRule == 1) { list.Add(new Claim(ClaimTypes.Role, "ChatAdministrator")); } if (userRight.ManageIterations == 1) { list.Add(new Claim(ClaimTypes.Role, "IterationManager")); } if (userRight.ManageUserdays == 1) { list.Add(new Claim(ClaimTypes.Role, "UserDays")); } if (userRight.UpdateUserRights == 1) { list.Add(new Claim(ClaimTypes.Role, "UpdateUserRights")); } list.ForEach(x => { principal.Identities.FirstOrDefault().AddClaim(x); }); var authProperties = new AuthenticationProperties { AllowRefresh = true, ExpiresUtc = DateTimeOffset.Now.AddDays(1), IsPersistent = true, }; await HttpContext.SignOutAsync(); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, authProperties); }
public IActionResult GetByRights(UserRights rights) { ValidationResponse <IEnumerable <User> > validationResponse = _userService.GetByRights(rights); IEnumerable <UserResponseModel> userResponse = _mapper.Map <IEnumerable <User>, IEnumerable <UserResponseModel> >(validationResponse.ResponseData); return(Ok(userResponse)); }
public void checkRightsTest_Fail() { var expected = false; var actual = UserRights.checkRights(UserRights.rights.none, UserRights.rights.create); Assert.AreEqual(expected, actual); }
public void getRightsNumericvalueTest_Success() { var expected = 15; var actual = UserRights.getRightsNumericvalue(UserRights.rights.FullControl); Assert.AreEqual(expected, actual); }
public void checkRightsTest() { var expected = true; var actual = UserRights.checkRights(UserRights.rights.FullControl, UserRights.rights.create); Assert.AreEqual(expected, actual); }
IEnumerable <User> IUserRepository.GetByRights(UserRights rights) { return(dbSet .AsNoTracking() .OrderBy(user => user.FullName) .Where(user => user.Rights == rights) .ToList()); }
public void InitPermissions() { addEmployeeButton.Enabled = UserRights.Any(d => d.Libelle_Droit == "writeEmployees"); dismissButton.Enabled = UserRights.Any(d => d.Libelle_Droit == "writeEmployees"); editButton.Visible = UserRights.Any(d => d.Libelle_Droit == "writeEmployees"); permissionButton.Enabled = UserRights.Any(d => d.Libelle_Droit == "writeEmployees"); addEmployeePhotoPictureBox.Visible = UserRights.Any(d => d.Libelle_Droit == "writeEmployees"); }
public clsUser(string userid, string username, UserRights userrights, string loginName, string directorid) { this._userid = userid; this._username = username; this._permission = userrights; this._loginName = loginName; this._directorid = directorid; }
private RefreshDataResponseModel RefreshData(decimal userClass) { decimal[] V2ConfTypes = { 1, 2, 3, 4, 7 }; var types = new decimal[] { 1, 3, 7, 11, 12 }; var sections = new decimal[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 21 }; var committees = Db.gen_committees.Where(r => types.Contains(r.type)).Where(p => sections.Contains(p.section)).Where(p => p.id != 143).Where(t => t.active).OrderBy(t => t.description).ToList(); RefreshDataResponseModel response = new RefreshDataResponseModel() { AreasOfPracticeDict = Db.mem_areasofpractice.ToDictionary(r => r.id, t => t.description), CommitteesDict = committees.ToDictionary(g => g.id, r => r.description) }; var access = UserRights.V2Login(Db, Request); //var confdelegate = // Db.conf_delegate.FirstOrDefault( // c => // c.record_id == access.Session.record_id && c.conference_id == 637 && c.status_id == 1 && // V2ConfTypes.Contains(c.type_id)); var profile = GetProfile(access.Session.record_id); var ImAttending = Db.conf_delegate.Any(r => r.conference_id == AppSettings.ConferenceId && r.record_id == profile.Id); IEnumerable <string> headerValues; var correctAppVersion = false; if (Request.Headers.TryGetValues("AppVersion", out headerValues)) { var version = headerValues.FirstOrDefault(); correctAppVersion = version != null; if (correctAppVersion) { double doubleVersion; double.TryParse(version, out doubleVersion); if (doubleVersion != 0) { correctAppVersion = doubleVersion >= 3; } else { correctAppVersion = false; } } } if (AppSettings.ShowConferenceDetails && ImAttending && correctAppVersion) { var conf = Db.conf_conference.SingleOrDefault(r => r.id == AppSettings.ConferenceId); response.Conference = new Conference(); response.Conference.ShowDetails = true; response.Conference.Url = AppSettings.ConferenceUrl; response.Conference.StartDate = AppSettings.ConferenceStart; response.Conference.FinishDate = AppSettings.ConferenceEnd; //conf.end_date; response.Conference.ConferenceId = AppSettings.ConferenceId; } return(response); }
public ActionResult MenuHtml() { if (UserRights.Count == 0) { ViewBag.MenuStr = ""; return(View()); } string rurl = Request.Url.AbsolutePath.Remove(0, 1); //当前请求的页面url string[] urls = rurl.Split('/'); rurl = urls[0] + "/" + urls[1]; var rt = GetSubMenu(UserRights, rurl, 0); var htmlMenu = new StringBuilder(""); var rootRight = UserRights.First(p => p.ParentId == 0); var tempUserRights = UserRights.Where(p => p.ParentId == rootRight.RightId && p.RightType == 0 && (p.ModuleName == null ? "" : p.ModuleName).ToLower() == Session["moduleName"].ToString().ToLower()).OrderBy(p => p.ShowOrder); foreach (var right in tempUserRights) { string path = right.Path.IndexOf("/", System.StringComparison.Ordinal) >= 0 ? right.Path : "#"; string title = CodeHelper.GetNavigateString(right.RightName); if (string.IsNullOrEmpty(title)) { title = right.RightName; } if (path != "#" && !path.StartsWith("/")) { path = "/" + path; } var subRight = UserRights.Where(p => p.ParentId == right.RightId && p.RightType == 0); htmlMenu.AppendFormat( "<li name='{0}'><a class='" + ((rt != null && rt.Path.ToLower() == right.Path.ToLower()) ? "On" : "") + "' href='{3}'>{1}</a>{2}{4}", right.RightName, title, (subRight.Any() ? "<i></i>" : ""), (subRight.Any() ? "#" : path), (subRight.Any()?"<ul>":"")); foreach (var c in subRight.OrderByDescending(p => p.ShowOrder)) { var p = c.Path; if (!p.StartsWith("/")) { p = "/" + p; } var t = CodeHelper.GetNavigateString(c.RightName); if (string.IsNullOrEmpty(t)) { t = c.RightName; } htmlMenu.AppendFormat("<li><a href='{0}'><span>{1}</span></a></li>", p, t); } htmlMenu.Append(string.Format("{0}</li>", (subRight.Any() ? "</ul>" : ""))); } ViewBag.MenuStr = htmlMenu.ToString(); return(View()); }
public async Task <ActionResult <userDTO> > Register(RegisterDto registerDto) { if (await UserExistwithUserName(registerDto.UserName)) { return(BadRequest("User Name is already taken")); } if (await UserExistWithDetails(registerDto)) { return(BadRequest("User Already Registered with the Details.Please contact Administrators")); } var hmac = new HMACSHA512(); var user = new AppUser { UserName = registerDto.UserName.ToLower(), PasswordHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(registerDto.Password)), PasswordSalt = hmac.Key, Name = registerDto.Name, FamilyGroupId = registerDto.FamilyGroupId, Mobile = registerDto.Mobile, Address = registerDto.Address, EmailAddress = registerDto.EmailAddress, Gender = registerDto.Gender, CreatedDttm = DateTime.Now, DateOfBirth = registerDto.DateOfBirth }; context.Users.Add(user); await context.SaveChangesAsync(); bool isAdmin, isverified; isAdmin = false; isverified = false; UserRights adminuser = new UserRights(); adminuser = await context.UserRights.SingleOrDefaultAsync(x => x.UserId == user.Id && x.RightsId == 1); if (adminuser != null) { isAdmin = true; } UserRights verifieduser = new UserRights(); verifieduser = await context.UserRights.SingleOrDefaultAsync(x => x.UserId == user.Id && x.RightsId == 2); if (verifieduser != null) { isverified = true; } return(new userDTO { Username = user.UserName, Token = tokenService.createToken(user), isadmin = isAdmin, isverificationadmin = isverified }); }
public UserNote(Guid id, UserRights rights, Guid userId, User user, Guid noteId, Note note) { Id = id; Rights = rights; UserId = userId; User = user; NoteId = noteId; Note = note; }
/// <summary> /// Получить схему из кеша или от сервера с проверкой прав на неё /// </summary> private SchemeView GetSchemeView(int viewID, UserRights userRights) { if (!userRights.GetUiObjRights(viewID).ViewRight) { throw new ScadaException(CommonPhrases.NoRights); } return(AppData.ViewCache.GetView <SchemeView>(viewID, true)); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public EventFilter(int limit, UserRights rights) : this(limit) { ArgumentNullException.ThrowIfNull(rights, nameof(rights)); if (!rights.ViewAll) { AddCondition("ObjNum", FilterOperator.In, rights.GetAvailableObjs().ToList()); } }
public HttpResponseMessage GetV2() { var access = UserRights.V2Login(Db, Request); if (access.HasErrors) { return(Request.CreateErrorResponse(access.ErrorCode, access.ErrorMessage)); } return(Request.CreateResponse(HttpStatusCode.OK, RefreshData(access.Session.C_records.@class))); }
public static Collection <UserRights> ConvertRightsStringToCollection(string rights) { UserRights userRightObject; Collection <string> commonRights; Collection <UserRights> usersRightsCollection = new Collection <UserRights>(); Collection <string> SystemCommonRights = GetCommonRights(); List <string> tempUserRights = new List <string>(); try { tempUserRights = rights.ToLower().Split(';').ToList(); } catch (Exception e) { //throw new Exception("exception happened here 2 : ", e); } try { //foreach user foreach (string tempUserRight in tempUserRights) { commonRights = new Collection <string>(); var userRightsInfo = ConvertStringtoRights(tempUserRight); if (!string.IsNullOrEmpty(userRightsInfo.RightsList)) { var rightsList = userRightsInfo.RightsList.Split(',').ToList(); foreach (string right in rightsList) { if (SystemCommonRights.Contains(right.ToUpper())) { commonRights.Add(right.ToUpper()); } } if (commonRights.Count > 0) { userRightObject = new UserRights(UserIdType.Email, userRightsInfo.EmailAddress, commonRights); usersRightsCollection.Add(userRightObject); } } } } catch (Exception e) { //throw new Exception("exception happened here 2 : ", e); } return(usersRightsCollection); }
public static bool IsRights(int profile, UserRights rights) { bool flag = false; UserRights userRights = (UserRights)profile; if ((rights & userRights) == rights) { flag = true; } return(flag); }
public ActionResult Edit([Bind(Include = "UserId,CanBuy,CanReview")] UserRights userRights) { if (ModelState.IsValid) { db.Entry(userRights).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(db.Users, "Id", "Email", userRights.UserId); return(View(userRights)); }
public HttpResponseMessage GetV2(decimal userId) { var access = UserRights.V2Login(Db, Request); if (access.HasErrors) { return(Request.CreateErrorResponse(access.ErrorCode, access.ErrorMessage)); } return(Request.CreateResponse(HttpStatusCode.OK, GetProfile(userId, access))); }
public void Delete(UserRights entity) { try { entities.UserRightss.Remove(entity); } catch (Exception ex) { throw ex; } }
public void Add(UserRights entity) { try { entities.UserRightss.Add(entity); } catch (Exception ex) { throw ex; } }
public static Boolean validateRights(UserRights right, String rightString) { if (rightString[(int)right] == '1') { return(true); } else { return(false); } }
private void SetUserRights(UserRights userRights) { this.userRights = userRights; userAddUrlCheckBox.Checked = (userRights & UserRights.AddUrl) == UserRights.AddUrl; userEditUrlCheckBox.Checked = (userRights & UserRights.EditUrl) == UserRights.EditUrl; userAddCategoryCheckBox.Checked = (userRights & UserRights.AddCategory) == UserRights.AddCategory; userEditCategoryCheckBox.Checked = (userRights & UserRights.EditCategory) == UserRights.EditCategory; userAddUserCheckBox.Checked = (userRights & UserRights.AddUser) == UserRights.AddUser; userRemoveUserCheckBox.Checked = (userRights & UserRights.RemoveUser) == UserRights.RemoveUser; }
public async Task <dynamic> Update([FromBody] UserRights userRights) { if (_postUserRightsProcessor != null) { return(await _putUserRightsProcessor.PutExistingUserRecord(userRights, _cloudantService)); } else { return(new string[] { "No database connection" }); } }
public void Attach(UserRights entity) { try { entities.UserRightss.Attach(entity); entities.Entry(entity).State = EntityState.Modified; } catch (Exception ex) { throw ex; } }
//Returns a list of user ids which we have had connections with public HttpResponseMessage GetConnections() { var access = UserRights.V2Login(Db, Request); if (access.HasErrors) { return(Request.CreateErrorResponse(access.ErrorCode, access.ErrorMessage)); } var result = P2PMessagingLayer.GetconnectedUserIds(CmsDb, Db, (int)access.Session.record_id); return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public HttpResponseMessage Put(P2PThreadHideRequestModel request) { var access = UserRights.V2Login(Db, Request); if (access.HasErrors) { return(Request.CreateErrorResponse(access.ErrorCode, access.ErrorMessage)); } var result = P2PMessagingLayer.HideMessageThread(CmsDb, request.ThreadId, (int)access.Session.record_id); return(Request.CreateResponse(HttpStatusCode.OK, result)); }
/// <summary> /// Constructor. Use this method to construct an external user. /// </summary> /// <param name="userLogin">The acronym of the user.</param> /// <param name="userFullName">The full name of the user.</param> /// <param name="rights">The rights of the user.</param> /// <param name="canCreate">Indicates whether the user can create articles and organize the hierarchy of portals/categories/articles.</param> public User(string userLogin, string userFullName, UserRights rights, bool canCreate) : this(false, userLogin, string.Empty, string.Empty, userFullName, rights, canCreate) { }
/// <summary> /// Constructor. /// </summary> /// <param name="isInternal">Whether the user is internal or external (true for an intranet user).</param> /// <param name="userLogin">The acronym of the user.</param> /// <param name="firstName">The first name of the user.</param> /// <param name="lastName">The last name of the user.</param> /// <param name="fullName">The full name of the user (for customers).</param> /// <param name="rights">The rights of the user.</param> /// <param name="canCreate">Indicates whether the user can create articles and organize the hierarchy of portals/categories/articles.</param> public User(bool isInternal, string userLogin, string firstName, string lastName, string fullName, UserRights rights, bool canCreate) { this.m_IsInternal = isInternal; this.m_UserLogin = userLogin; if (isInternal) { this.m_FirstName = firstName; this.m_LastName = lastName; } else this.m_FullName = fullName; this.m_Rights = rights; this.m_CanCreate = canCreate; }
internal void EditPermissions(Project project, UserRights userRights, GuestRights guestRights) { string url = GetBaseUrl("editpermissions"); StringBuilder builder = new StringBuilder(url); builder.Append("&projectid="); builder.Append(project.ID); builder.Append("&useruseradd="); builder.Append((userRights & UserRights.AddUser) == UserRights.AddUser ? "yes" : "no"); builder.Append("&useraddurl="); builder.Append((userRights & UserRights.AddUrl) == UserRights.AddUrl ? "yes" : "no"); builder.Append("&userurledit="); builder.Append((userRights & UserRights.EditUrl) == UserRights.EditUrl ? "yes" : "no"); builder.Append("&useraddcat="); builder.Append((userRights & UserRights.AddCategory) == UserRights.AddCategory ? "yes" : "no"); builder.Append("&usercatedit="); builder.Append((userRights & UserRights.EditCategory) == UserRights.EditCategory ? "yes" : "no"); builder.Append("&guestread="); builder.Append((guestRights & GuestRights.Read) == GuestRights.Read ? "yes" : "no"); builder.Append("&guestaddurl="); builder.Append((guestRights & GuestRights.AddUrl) == GuestRights.AddUrl ? "yes" : "no"); builder.Append("&guesturledit="); builder.Append((guestRights & GuestRights.EditUrl) == GuestRights.EditUrl ? "yes" : "no"); builder.Append("&guestaddcat="); builder.Append((guestRights & GuestRights.AddCategory) == GuestRights.AddCategory ? "yes" : "no"); builder.Append("&guestcatedit="); builder.Append((guestRights & GuestRights.EditCategory) == GuestRights.EditCategory ? "yes" : "no"); url = builder.ToString(); XmlDocument doc = SendRequest(url); }
public static User newFromStringWithAccessLevel(string source, UserRights accessLevel) { return newFromStringWithAccessLevel(source, 0, accessLevel); }
public static User newFromStringWithAccessLevel(string source, uint network, UserRights accessLevel) { User u = newFromString(source, network); u._accessLevel = accessLevel; return u; }
/// <summary> /// The new from string with access level. /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="network"> /// The network. /// </param> /// <param name="accessLevel"> /// The access level. /// </param> /// <returns> /// The <see cref="LegacyUser"/>. /// </returns> public static LegacyUser NewFromStringWithAccessLevel(string source, uint network, UserRights accessLevel) { LegacyUser u = NewFromString(source, network); if (u == null) { return null; } u.accessLevel = accessLevel; return u; }
/// <summary> /// The new from string with access level. /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="accessLevel"> /// The access level. /// </param> /// <returns> /// The <see cref="LegacyUser"/>. /// </returns> public static LegacyUser NewFromStringWithAccessLevel(string source, UserRights accessLevel) { return NewFromStringWithAccessLevel(source, 0, accessLevel); }
public bool HasRight(UserRights.Collection right) { APIResult res; res = WebAPI_Authorization.HasRight(new HasRightPost { Right = right },AppSetting.id.ToString()).Result; return res.Result; }
private void UserRightCheckedChanged(object sender, EventArgs e) { CheckBox box = sender as CheckBox; if (box == null) return; int tag = Int32.Parse(box.Tag.ToString()); if (box.Checked) userRights = userRights | (UserRights)tag; else userRights = userRights ^ (UserRights)tag; }
public static bool IsSet(Int64 var, UserRights flag) { return (var & (Int64)flag) == (Int64)flag; }