سلام
چطور میشه در mvc با استفاده از Identity کاربرها رو با استفاده از نام کاربری و کلمه عبور Active Direcoty وارد سیستم کرد.
باتشکر
First step: setting the parameters to use AD:
In your the section of your web.config file, set the following:
<authentication mode="Windows" />
<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider">
<providers>
<clear />
<add
name="AspNetWindowsTokenRoleProvider"
type="System.Web.Security.WindowsTokenRoleProvider"
applicationName="/" />
</providers>
</roleManager>
Now, you will be able to directly use methods from the System.Web.Security namespace.
If you want to restrict the access to a View to only people members of the "groupName" group of your AD:
You only have to decorate your controller action like that:
[Authorize(Roles = @"DOMAIN\groupName")]
Public ActionResult Index()
{...}
If you want to do treatments based on the AD groups of users:
Use methods such as "IsInRole(rolename)" in your treatments:
if (User.IsInRole("DOMAIN\\groupName"))
{
// Do what you want
}
EDIT: implementation of the problematic: here you should save the sAMAccountName of the group affected to your task when you create the task. Then when a user wants to mark the task as complete, just check:
if (User.IsInRole("DOMAIN\\" + sAMAccountNameOfTheGroupDedicatedToYourTask))
{
// Mark as complete
}
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)