Hi,
Does anybody know how to access windows nt user's credentials in an ASP program?
I want to find out the role, user group of an user who logs in to the system. I don't know how to use windowsprincipal.isinrole.
Please help.
First you have to use IE.
In the IIS sevecis manager you have to set the direcotry security to integrated windows authentication (this part only works if users have IE).
This means that when a user visits your site the and the user is loged in on your network he or she will automatically send his or her login name.
You can get this login name with the following code:
User.Identity.Name
This will return a string (domain\username)
To see if a user is in a role you can use:
User.IsInRole("admin"
You can use the web.config file to allowe and deny users, the file will look like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<authorization>
<deny users="*" />
<allow users="boogiewoogie" /> <!-- Allow all users -->
<!-- <allow users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
<deny users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
-->
</authorization>
</system.web>
</configuration>
Sorry, it seems that the isinrole is for forms varification so you must make the roles first than add users to it and then check if a user is in a role.
In asp I used to use hasaccess and let a group of nt users have access to file.
this is the code:
dim objFileSys
dim objFile
dim objChk
set objChk = server.CreateObject ("MSWC.Permissionchecker"
set objFileSys = Server.CreateObject("Scripting.FileSystemObject"
set objFile = objFileSys.GetFile("C:\Inetpub\
if objChk.HasAccess(objFile) then
' this user is ok
end if
This way if I wanted to add/remove users to use an Intranet application I just added or removed them from the user group.
I have yet to find out how to do this with .net.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.