简体   繁体   English

使用当前登录用户的UserId过滤记录

[英]filter records using UserId of currently logged in user

I have got an application where by a user can add other lists of Staff with his user ID. 我有一个应用程序,用户可以在其中添加具有其用户ID的Staff的其他列表。
I have roles where by if one is in role of staff, when logged in he can see also list of what was added by other staff. 我的角色是,如果一个人充当员工角色,则登录后他还可以看到其他员工添加的内容的列表。
What I need to do filter what each staff will see in a drop-down, ie Each should only view the records he added according to his ID. 我需要做的是过滤每个员工在下拉列表中看到的内容,即每个员工只能根据自己的ID查看他添加的记录。
How I like to do it is check the user Id of currently logged in user, and only let him view his records which are being populated in a drop-down combo-box. 我喜欢这样做是检查当前登录用户的用户ID,并且只允许他查看他的记录,这些记录正在下拉组合框中。

Suggestions about this appreciated 关于这个赞赏的建议

While adding other Staff, you need to store also that who created this staff. 在添加其他人员时,您还需要存储创建此人员的人员。

Now, when data for the dropdown is fetched, also get the CREATED_BY attribute of the dropdown. 现在,当获取下拉菜单的数据时,还要获取下拉菜单的CREATED_BY属性。 Say, you get the value of the dropdown and text field of the dropdown. 假设您获得下拉列表的值和下拉列表的文本字段。 In your textfield, it will be the your staff names and in your value field it will be your dropdwon value and CREATED_BY field separated by a splitter(eg: ~ or :) Now, loop in the value by splitting it where 0th item is your dropdown value and 1th item is CREATED_BY attribute. 在您的文本字段中,将是您的员工姓名,在您的值字段中,将是您的dropwwon值和CREATED_BY字段,并用分隔符分隔(例如:〜或:)。下拉值和第1个项目是CREATED_BY属性。

Compare it with the logged in user id and display what you require. 将其与登录的用户ID进行比较,并显示您的要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 检索仅与当前登录用户有关的记录 - Retrieve records only related to the currently logged in user 如何通过 sql 和 c# 网络中的参数当前登录的用户的用户 ID - how can to pass the userid of the user is currently logged in as a parameter in sql with c# net 使用C#获取当前登录用户的ADS组列表 - Get the list of ADS groups of the currently logged in user using C# 如何使用C#通过他的ID获取当前登录用户? - How to get currently logged in user by his ID using C#? 如何检查当前登录的用户是否正在使用漫游配置文件? - How to check if the currently logged on user is using roaming profile? 获取当前登录用户的详细信息 - Get the details of currently logged in user 检查当前没有用户登录到Windows - Check if no user is currently logged on to Windows 在ASP.NET中获取已登录用户的userID - Getting the userID of a logged in User in ASP.NET 如何使用 UserManager 按 ID、名称、email 或其他搜索条件获取用户(不是当前登录的用户)? - How can I get a user (not the currently logged in user) by Id, name, email or other search criteria, using UserManager? 为什么EF尝试插入当前登录的用户? - Why is EF trying to insert currently logged in user?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM