Hi All,
I have a typical problem. We have established product developed in ASP. Now I want to add security and access cotrol to upload directory and files. I could not find anything that can help me to write code in ASP. But in ASP.net C# and C++ there is lot. By comparison, I wrote in ASP something like this:

Public Sub AllowAccess(FullPath, UserNameForFullAccess, Access_Mask)
Dim oFileSecurity, oFile
oFile = oFile.FileInfo(FullPath)
oFileSecurity = oFile.GetAccessControl()
if (len(trim(UserNameForFullAccess)) > 1 ) then
if (len(Access_Mask)>1) then
select case Access_Mask
case GENERIC_ALL
oFileSecurity.AddAccessRule(New System.Security.AccessControl.FileSystemAccessRule(UserNameForFullAccess, System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Allow))
oFile.SetAccessControl(oFileSecurity)
case GENERIC_EXECUTE
oFileSecurity.AddAccessRule(New System.Security.AccessControl.FileSystemAccessRule(UserNameForFullAccess, System.Security.AccessControl.FileSystemRights.ReadAndExecute, System.Security.AccessControl.AccessControlType.Allow))
oFile.SetAccessControl(oFileSecurity)
case GENERIC_READ
oFileSecurity.AddAccessRule(New System.Security.AccessControl.FileSystemAccessRule(UserNameForFullAccess, System.Security.AccessControl.FileSystemRights.Read, System.Security.AccessControl.AccessControlType.Allow))
oFile.SetAccessControl(oFileSecurity)
case GENERIC_WRITE
oFileSecurity.AddAccessRule(New System.Security.AccessControl.FileSystemAccessRule(UserNameForFullAccess, System.Security.AccessControl.FileSystemRights.Read, System.Security.AccessControl.AccessControlType.Allow))
oFile.SetAccessControl(oFileSecurity)
oFileSecurity.AddAccessRule(New System.Security.AccessControl.FileSystemAccessRule(UserNameForFullAccess, System.Security.AccessControl.FileSystemRights.Write, System.Security.AccessControl.AccessControlType.Allow))
oFile.SetAccessControl(oFileSecurity)
case FILE_ACCESS_ALL
oFileSecurity.AddAccessRule(New System.Security.AccessControl.FileSystemAccessRule(UserNameForFullAccess, System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Allow))
oFile.SetAccessControl(oFileSecurity)
case MAXIMUM_ALLOWED
oFileSecurity.AddAccessRule(New System.Security.AccessControl.FileSystemAccessRule(UserNameForFullAccess, System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Allow))
oFile.SetAccessControl(oFileSecurity)
end select
end if
end if
oFile = Nothing
oFileSecurity = Nothing
End Sub

Public Sub RevokeAccess(FullPath, UserNameForDeniedAccess)
Dim oFileSecurity, oFile
oFile = FileInfo(FullPath)
oFileSecurity = oFile.GetAccessControl()
if (len(trim(UserNameForDeniedAccess)) > "") then
oFileSecurity.RemoveAccessRule(New System.Security.AccessControl.FileSystemAccessRule(UserNameForDeniedAccess, System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Allow))
oFile.SetAccessControl(oFileSecurity)
End if
oFile = Nothing
oFileSecurity = Nothing
End Sub

This code fulfills my need but problem is this does not work in ASP. Can somebody help me how can I achieve this in ASP?

Nitin Rajurkar

I take it you are using IIS?

Hi Jbennet,
You are right. I am using IIS and Internet Explorer 6.0 and above. I created ActiveX and accessing these through it.

Any simple solution you have?

Nitin

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.