How to only display items created by the current logged in user only in asp.net core - asp.net-core-mvc

I want to only display items created by the current logged in user only in asp.net core
I created an asp.net core mvc application in which users can enter data to them.
Now i want to display only logged in user data but i don't know how to make it work please help me

Related

Windows Authentication using MVC5, display Username at the top of every View

I am developing a MVC5 application for the DOE. We use windows authentication to login to our computers. I need help getting the users Name when logged in to be display "Welcome, Username"(across all pages) when they navigate to site. My problem is that when I navigate to the page it displays our ID which is what we use to login, i.e. i5456 and password. It would be much appreciated if someone would assist me and walk me through how to set this up.
I have already disabled Forms auth and enabled windows auth in VS 2013. I have tried using #User.Identity.Name in my SiteLayout, but like I said the ID is the only thing displayed. I'm not sure how to setup my model or view, or if I even have to. Is there a way to retrieve the Username so it can be displayed instead of the ID?
Try this #User.Identity.GetUserName() in your view
works for me

How to implement role based authorization in asp.net mvc3

I'm working on a school project and I need to implement Role-based authorization in an ASP.NET mvc3 application. Currently the application only stores the user's role in a field in the database and there is only one login page. I need to alter the entire application in other for it to grant different content to different users including admin, supervisor and counselors (counselors are able to input new client info and edit and view client information that they inputted. Supervisors can view and edit all client info and also view and edit counselor info. Admin has crud access to everything on the application.)
I'm not sure about what other info to provide about the application but i'll really appreciate any help i can get as i am new to ASP.net mvc as a whole. Most of the tutorials i found focus on specific piece of the role based approach. I need more of a bottom-up approach to implementing the roles and its authorization.
Take a look at ASPNET configuration tool. I believe that it's what you're looking for:
Visual Studio 2013 and ASP.NET Web Configuration Tool
http://msdn.microsoft.com/en-us/library/yy40ytx0.aspx

Kill a session from another session with .NET MVC3

I use .NET MVC3 framework with razor and my question is simple, how to kill a session from another session ?
I would like to make an admin view with the list of users and the user's session ID and from this view i would add a button or a link which allow me to kill the session of a specific users.
It is possible ?
Thanks for your response
You could keep a list of logged in users somewhere on the server. Once a user logs in you could add it to your logged in users list. Then you could write a custom Authorize attribute which upon successful authorization will verify if the user is in the list of logged in users and only then allow access. And when under administrator account you could have some action which removes users from this global users list.

YAF 1.9.5.5: Integrate MVC 3 with YAF (login and register)

i have a MVC 3 project and want to integrate YAF forum inside of my project, but i dont know how to make a register page and login page (in MVC 3 project) that when i register an account, YAF create an user too, the same with login page, i just want user can register and login in my MVC project and then go to the YAF forum
Thanks and sry 4 my E :)
The YAF.Providers.YafMembershipProvider module makes a call to dbo.yaf_prov_createuser stored procedure in the DB when creating users.
You can call that yourself to create a user. You'll be bypassing a few validation routines so you need to make sure the user info you pass in is unique (i.e. email and username).
Then all you're missing is to set yaf_prov_Membership.IsApproved = True once you've validated the email.

MVC 3 ASP.NET Roles-Authorize Attribute

I am getting user roles from Active Directory and I am binding the same roles to ASP.NET Membership Roles.
I want to control the display for the various Views in Controller by using
[Authorize(roles="Admin")]
But Which ever role I specify, The View just doesn't display. If I take out the [Authorize(roles="Admin")] it works.
Does Authorize uses ASP.NET Membership roles? if so, Why I am getting this error?
Am I missing anything? Any Ideas?
Thank you
IIRC if you use AD roles it works with groups and you need to specify the domain:
[Authorize(Roles = #"MYDOMAIN\SomeDomainGroup")]
Now if the user accessing the site belongs on the given AD group he will be granted access.
Assuming you are using the VS built in server and you are getting a blank page - the built in development server will display a blank page instead of prompting for credentials.
Buried way down in a note on this page
Note:
If you are using the Visual Studio Development server, you are not prompted for credentials and you see only a blank page.

Resources