Here is a working sample ASP.NET MVC 4 application that uses Windows Authentication with SQL Server Role Provider.
In the web.configfile under <system.web> section:
<roleManager enabled="true" defaultProvider="SqlRoleProvider">
<providers>
<add name ="SqlRoleProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="AspNetMembershipConnString"
applicationName="MembershipAndRoleProviderSample"/>
</providers>
</roleManager>
This tells the ASP.NET runtime to use SQL role provider and indicates which connection string to use to locate the database.
Because we are using SQL Role Provider, we need a database where users and roles are stored. To create the database use aspnet_regsql.exe command (on my windows 10 pro machine its under C:\Windows\Microsoft.NET\Framework\v4.0.30319\) which allows to create the schema that holds the users and roles.
Note: When creating the schema through this tool, make sure the database name is the same as given in your connection string in the web.config file (coming up next).
Back to the web.config file add the connection string:
<connectionStrings>
<add connectionString="DATA SOURCE = PersonalLaptop\SQLEXPRESS2014; INITIAL CATALOG = AspNetMembership; INTEGRATED SECURITY = SSPI;"
name="AspNetMembershipConnString" providerName="System.Data.SqlClient"/>
</connectionStrings>
Make sure the name of connection string is the same as the one in the SQL role provider section.
Note: You don't need the membership provider because you are using Integrated Windows Authentication mode.
Create a role and add a user
There are two ways to do this:
Open up the SQL database where aspnet_regsql.exe has created the tables and stored procs. Create a new record in aspnet_Users, aspnet_Applications, aspnet_UsersInRoles and aspnet_Roles tables. Since you are using the windows authentication therefore make sure that you add the windows user name (Fully Qualified Domain Name / Local User Name) in the aspnet_Users table.
In the HomeController's Index method use the code:
Roles.CreateRole("SuperDuperUsers");
Roles.AddUserToRole("<WindowsUserName>", "SuperDuperUsers");
This will create the role and the user will be added into that role for you.
I have uploaded the sample ASP.NET MVC 4 application on GitHub for you.
In the GitHub repository, the SqlScriptOfTheDatabase.sql file contains the schema that is created to store the users and roles and their relationship. You can use this instead of using the aspnet_regsql.exe command if you want.