Reputation: 140
I created asp.net webpage , i want to log on my asp page using windows username and password when login button click. i have search some code(http://www.codeproject.com/Articles/37558/Windows-Authentication-Using-Form-Authentication) in net for login my asp page. It works for my local user name and password but i want to access Specific domain group members to my asp.net page
Someone help me...
Upvotes: 0
Views: 6111
Reputation: 10565
To provide/restrict access to specific users/groups, appropriate entries needs to be done in Web.config
.
In Windows authentication names are entered in the format DomainName\UserName
or ComputerName\UserName
.
You need to use the same format when listing users in the authorization rules. For example, if you have the user accounts john and nolan on a computer named FARIAMAT, you can use these authorization rules. Note the users
attribute in <allow>
element.
<authorization>
<deny users="?" />
<!-- permit only specific users to have access -->
<allow users="FARIAMAT\john,FARIAMAT\nolan" />
<deny users="*" />
</authorization>
To permit all users of an NT Group named Managers to have access to your resources, use the following code. Note the roles
attribute in <allow>
element.
<configuration>
<system.web>
<authorization>
<!-- Format is:: <allow roles="DomainName\WindowsGroup" /> -->
<allow roles="domainname\Managers" />
<deny users="*" />
</authorization>
</system.web>
</configuration>
NOTE::
Windows groups are used as roles and they take the form domainName\windowsGroup
. Groups such as Administrators
are referenced by using the BUILTIN
prefix as:
<authorization>
<allow users="DomainName\john, DomainName\nolan" />
<allow roles="BUILTIN\Administrators, DomainName\Manager" />
<deny users="*" />
</authorization>
Upvotes: 7