Home What's New
User Manual
|
Chapter 6. User Impersonation and Permissions
What is Impersonation
The LogonUser accepts three required parameters: a domain name, username and password.
Once a successful call to the LogonUser method is made, the rest of the script on
that ASP page will run under the security context of the specified user account.
For example:
' Upload to a remote drive
If an empty string is specified for the domain name, the local machine will be used
to validate the username and password.
On Windows NT/IIS4, if your virtual directory has the "Run in separate memory space"
option checked, the current user (IUSR_xxx) must have the
"Act as part of the operating system" privilege or you will get the error
A required privilege is not held by the client.
On Windows 2000/IIS5, you must set the "Application Protection" option to Low
(IIS Process) on your virtual directory to avoid the error
A required privilege is not held by the client.
The methods AllowAccess and DenyAccess add an allowance access control
entity (ACE) and a denial ACE, respectively,
to the file's Access Control List (ACL). These methods expect an NT username
or group name, and a set of flags, as parameters.
The methods RevokeAllowance and RevokeDenial
remove an allowance and denial ACE, respectively, from the file's ACL.
The sample files access.asp and access_upload.asp
demonstrate the usage of the NTFS methods by allowing
a user to select a file, specify a username/password to impersonate,
an account to call AllowAccess on, and an account to call DenyAccess on.
This is what the file access_upload.asp looks like:
<HTML>
' We use memory uploads, so we must limit file size
' Save to memory so that we can access form items before file hits the disk
Username = Upload.Form("username")
If Username <> "" Then
AllowName = Upload.Form("ALLOW")
' Save files to disk
' Set allowance
' Set denials
Note that this file uses the constant GENERIC_ALL to grant/deny full access to the file.
This constant, along with other permission flags and file attributes, is defined
in the file AspUpload.inc which is included in this ASP page using the directive
<!--#include file="AspUpload.inc"-->
Some of the valid flag combination for the AllowAccess and DenyAccess methods include:
Read (RX):GENERIC_READ + FILE_GENERIC_EXECUTE
Click the link below to run this code sample:
File.Attributes = FILE_ATTRIBUTE_READONLY + FILE_ATTRIBUTE_HIDDEN
To add a new attribute while leaving existing attributes intact, you may say
File.Attributes = File.Attributes + FILE_ATTRIBUTE_READONLY
Don't forget to #include the file AspUpload.inc to be able to use the
constants such as FILE_ATTRIBUTE_READONLY, etc.
Copyright © 1998 - 2001 Persits Software, Inc. All Rights Reserved AspUpload® is a registered trademark of Persits Software, Inc. Questions? Comments? Write us! |