Intranet/Hosting Toolkit [table of contents]
[CFX_NFS]
v1.6 December 2nd 2001
CFX_NFS
OPEN-SOURCE
NT DLL for Cold Fusion 4.0.1 and up
Lewis A. Sellers
http://www.intrafoundation.com/ihtk.asp
products@intrafoundation.com

FOREWORD

This is an Allaire Cold Fusion Extension Tag (CFX). It is for use with Allaire Cold Fusion Servers 4.0.1 (and up) running on Microsoft NT. It was written by Lewis A. Sellers of Intrafoundation Software.

CFX_NFS allows you to manage shares, mapped network drives and NTFS file permissions (ACLs). This functionality, in combination with CFX_UserManager, allows you to create folders on shared or local drives they will allow or deny access depending on NT usernames and group memberships.

Please read the version history for current tag status before emailing questions.

C O N T E N T S

Foreword

General
Drives
Shares
Network drives
Permissions

Version History

top

G E N E R A L

ABOUT

<CFX_NFS ACTION="ABOUT">

The tag itself returns a couple variables back no matter what you do (NFSDescription, NFSVersion and NFSError). These are always available unless there is a catastrophic failure of the tag.

Additionally you can use the ABOUT function to return more detailed information on the tag. The fields returned are mostly only of interest for curiosity or in debugging a situation.

Note below that though the tag returns it's SerialNumber, it's not used currently, and hasn't been for a very long time, but probably will be again soon.

For the curious, it also proves the total number of lines of c/c++ that the current build was using. This includes the scant comments in the source code. For instance, this build of the tag has 3349 lines of code.

Description
The general product description.
Version
The version number of the software, ie 2.0.
Quality

The quality field will be one of the following four: "Alpha", "Beta", "Gamma" or "Omega". Quality relates the quality control status of the version of the tag you're currently using.

Alpha code is highly unstable and shouldn't be trusted for anything. Do not use on production machines.

Beta code is close to being finish and it is in a debugging phase. Do not use on production machines.

Gamma code is for use on production machines. As far as the beta testers have determined it works as it should.

When a product goes Omega that generally means it is long used Gamma code that is now no longer being maintained.

SubVersion
The subversion number of the software, ie 4 for "2.0beta4".
SerialNumber
Currently unused.
Lines
The total lines of c/c++ code in the software.
BuildDate
The ODBC DATETIME when the tag was last compiled (built).
Evaluation
Boolean field (0 or 1). 1 indicates the version of the tag you're using is a time-limited evaluation version. 0 is full commercial.
ExpirationDate
The ODBC DATETIME date when the tag will stop working.




THISSERVER

<CFX_NFS ACTION="THISSERVER">

New as of 2.0. Returns information about the server the cfx tag is installed on. For the most part these fields are of little practical use beyond curiosity. ComputerName and Username are exceptions however.

ComputerName relates the actual name given to the computer by netBIOS. This is also known as the server name if you prepend two-slashes to it. For instance, you're currently reading this on a machine that calls itself SASHA.

Username is the NT user name of the account that the ColdFusion application server is running under. It's installed by default to use SYSTEM. Some people will create an Administrator account specifically for ColdFusion to run under. You, btw, are using the account SYSTEM to run ColdFusion.

The fields returned are:

MaxUsernameLength, MaxPasswordLength and MaxPathLength are useful in that they give you the system's maximum character length for those three fields. This is information, which if you didn't already know of it, is useful in checking form fields for valid data.





SERVERS

<CFX_NFS ACTION="SERVERS">

This function returns a list of all servers in a domain. If you don't specify a domain, it assumes the local one.





DOMAINS

<CFX_NFS ACTION="DOMAINS">

This function returns a list of all domains.





NETWORKPRINTERS

<CFX_NFS ACTION="NETWORKPRINTERS">

This function returns a list of all network printers.





GETPRIMARYDOMAINCONTROLLER

<CFX_NFS ACTION="GETPRIMARYDOMAINCONTROLLER" [SERVERNAME=""] [DOMAINNAME=""]>

Retrieves the Primary (PDC) Domain Controller name. Of use mainly for NT4.

The function returns a SQL query with the following column:






top

D R I V E S

Primarily of use under the MS IIS web server, this group of functions allows you to manage access to network shares, drive-mapped network shares and folder permissions (ACLs). (These functions were experimentally introduced as of versions 1.13 to 1.15, and officially as of 2.0.)




LOCALDRIVES

<CFX_NFS ACTION="LOCALDRIVES" [QUERY=""]>

This functions returns a query containing detailed information about all the local drives on a machine. This, most importantly, includes their Format (FAT, NTFS, CDFS, etc) and the amount of space (in bytes) remaining on them. Note that all sizes are related in bytes and should be valid up to 2^63 (9,223,372,036,860,000,000) bytes.





REMOTEDRIVES

<CFX_NFS ACTION="REMOTEDRIVES" [QUERY=""]>

Asks remote servers to return a list of their drives in the LETTER/COLON format. The CF server must be a member of the Administrators or Account Operators groups for this to return valid data.






top

S H A R E S

SHARES

<CFX_NFS ACTION="SHARES" [QUERY=""]>

Lists all shares on the machine.





SHAREADD

<CFX_NFS ACTION="SHAREADD" SHARENAME="" PATH="" [COMMENT=""] [USERS="n"] [QUERY=""]>

This creates an alias to a drive:folder location that is shared by all applications on the network.

The PATH should (illogically) not end with a directory symbol (\). Drive:Path.

<CFX_NFS ACTION="SHAREADD" SHARENAME="name" PATH="drive:path" COMMENT="comment" USERS="n|0" QUERY="s">




SHAREDELETE

<CFX_NFS ACTION="SHAREDELETE" SHARENAME="">

Removes the specified share.

<CFX_NFS ACTION="SHAREDELETE" SHARENAME="name">





top

N E T W O R K D R I V E S




NETWORKDRIVES

<CFX_NFS ACTION="NETWORKDRIVES" [QUERY=""]>

Lists all network shares mapped to a local device/drive.

[There are currently some scope issues with NETWORKDRIVES and MAPNETWORKDRIVE that are being investigated. All other functions are, as far as is know, functioning correctly.]




MAPNETWORKDRIVE

<CFX_NFS ACTION="MAPNETWORKDRIVE"
LOCALNAME="[a-z]:"
REMOTENAME="\\servername\sharename"
[USERNAME=""]
[PASSWORD=""]
[RECONNECTATLOGIN="YES"]
>

Maps an unused local drive letter to a network share. Optional parameters are Username, Password and ReconnectAtLogon.

If you use PASSWORD="" then there will be no password. If you do not use PASSWORD then the default system password will be used.

[There are currently some scope issues with NETWORKDRIVES and MAPNETWORKDRIVE that are being investigated. All other functions are, as far as is know, functioning correctly.]
<CFX_NFS ACTION="MAPNETWORKDRIVE" LOCALNAME="Z:" REMOTENAME="\\WWW\public" RECONNECTATLOGON="YES">




DISCONNECTNETWORKDRIVE

<CFX_NFS ACTION="DISCONNECTNETWORKDRIVE" LOCALNAME="">

Disconnects a drive mapped from a network share.

<CFX_NFS ACTION="DISCONNECTNETWORKDRIVE" LOCALNAME="z:">





top

P E R M I S S I O N S

Windows NT and Windows 2000 have a file system available called NTFS (NT File System). Unlike the FAT file systems of DOS, Windows 95 and Windows 98 it has a file security system integrated into it. The security system is based on NT user and group names and various permission types you wish to assign them for a file or folder.

The true inner workings of the NTFS ACL are rather bizzare, but for your purposes this has all been distilled and isolated into three (3) access types (ALLOW, DENY and REVOKE) and eight (8) permissions (RWXDPOCF).

Usernames and Groups

When working with permissions you will name the user or group you are giving access to or denying from a file or folder. When created all files and folders have a few users or groups added to them by default, such as SYSTEM and Everyone. This is normal.

As a general rule you shouldn't delete or modify any of these unless you know what you're doing.

NOTE: Everyone is a special account name which simply signifies the permissions you grant to everyone else who you've not specifically named.

Access Types

There are only three basic access types involved with file security: ALLOW, DENY or REVOKE. If you add an ALLOW access type to a file for a user you grant them certain permissions (see below) such as being able to read the file or list the contents of a directory.

When you add a DENY to a file for a user, say "mrsmith", then you deny specific permissions to this file to the account "mrsmith".

REVOKE simply deletes all ALLOW or DENY access types on the specified file for the user named. That is, it removes all reference to the user from the file, good or bad.

Permissions

Permissions. In reality NT has a complicated tangle of permission masks and ACE structures, but we're not going to get into that. For our purposes there are only eight (8) permission types: RWXDPOCF. What they do varies slightly depending on whether we're talking about a file or a folder, but they are, more fully:

R "Read"
For files:

Allows viewing the file's data

For directories:

Allows viewing the names of files and subdirectories

W "Write"
For files:

Allows changing the file's data

For directories:

Allows adding files or subdirectories

X "eXecute"
For files:

Allows running the file if it is a program

For directories:

Allows changing to subdirectories in the directory

D "Delete"
For files:

Allows deleting the file

For directories:

Allows deleting the directory

P "change Permissions"
For files:

Allows changing the file's permissions

For directories:

Allows changing the directory's permissions

O "take Ownership"
For files:

Allows taking ownership of the file

For directories:

Allows taking ownership of the directory

C "Change"
Change (RWXD)
F "Full"
Full control (ie, RWXDPO)
r "Generic Read"
Generic read. For Windows 2000.
w "Generic Write"
Generic write. For Windows 2000.
x "Generic eXecute"
Generic Execute. For Windows 2000.
a "Generic All"
Generic All. For Windows 2000.

Under Windows NT folders, btw, are treated as any other file in many respects even though their permissions, as related above, have slightly different effects. The major difference with a folder you can specify the permissions that files created in that folder will inherit.

To add inherited permissions to a folder, simply use lowercased permission letters. That is: "rwxdpocf" instead of "RWXDPOCF". Note that inherited permissions are kept seperate from normal permissions. THIS is why when you do the PERMISSIONS function on a folder you will see double and triple entries for users. Some rows are for normal permissions. Others are for the inherited ones.

Permissions, btw, are valid only on NTFS file systems, which are an option under Windows NT and Windows 2000 only. You can not use any of this functionality on simple consumer-grade operating systems such as Windows 98.

SID and the AccessMask

Some of these functions may return the fields SID and AccessMask. You can safely just ignore these fields if you wish, but, for those of you who hardcore into managing your file permissions they can be very useful for working through the occasional difficult permissions problem that may come up. A SID, if you wish to know, is a Security Identifier. It's how windows actually uniquely identifies a user, etc across multiple domains. The AccessMask is the binary representation of the permissions codes (in this case, in hexidecimal).

As I said, you can completely ignore these fields. But if you need them they're there.




PERMISSIONS

<CFX_NFS ACTION="PERMISSIONS" FILE or FOLDER [QUERY=""]>

Lists permissions relating to a specific folder. Permissions (or ACL, ie Access Control Lists) is a somewhat complex thing under NT. In general however the purpose of permissions is to specific the name of a user or a group and what can of access they are to have to this folder.

Type
Allow, Deny
AccountType
"User" "Group" "Domain" "Alias" "Well Known Group" "Deleted Account" "Invalid type" "Unknown type"
IsInherited
This field is a simple way to determine if the row refers to (inherited) directory-related permissions or not.

Is is possible for a file to have permissions set for a user that no longer exists. In this case both username and domain will be blank.x

<CFX_NFS ACTION="PERMISSIONS" FOLDER="w:\user\lsellers" QUERY="lsellers">




SEARCHPERMISSIONS

<CFX_NFS ACTION="SEARCHPERMISSIONS" FILE="" or FOLDER="" TYPE="" [QUERY=""]>

Similiar to PERMISSIONS, this allows to to specify the USERNAME and TYPE you are specifically looking for. It returns only records matching these.

TYPE can be of the strings: "Allow", "Deny" or "Any".

<CFX_NFS ACTION="SEARCHPERMISSIONS" FOLDER="w:\user\mrsmith\" USERNAME="mrsmith" TYPE="DENY">




PERMISSIONALLOW

<CFX_NFS ACTION="PERMISSIONALLOW" FILE="" or FOLDER="" USERNAME="" or GROUP="" PERMISSION="">

Grants access permissions to a specific user or group.

<CFX_NFS ACTION="PERMISSIONALLOW" FOLDER="w:\user\mrsmith" USERNAME="mrsmith" PERMISSION="RWXD">
<CFX_NFS ACTION="PERMISSIONALLOW" FOLDER="w:\user\mrsmith" USERNAME="mrsmith" PERMISSION="RWXD" INHERIT="YES">
<CFX_NFS ACTION="PERMISSIONALLOW" FOLDER="w:\user\mrsmith\papers\" GROUP="techgroup" PERMISSION="RX">
<CFX_NFS ACTION="PERMISSIONALLOW" FILE="w:\user\mrsmith.finger.txt\" USERNAME="mrsmith" PERMISSION="RW">




PERMISSIONALLOW

<CFX_NFS ACTION="PERMISSIONDENY" FILE="" or FOLDER="" USERNAME="" or GROUP="" PERMISSION="">

Denies access to the folder for a specific user or group.

<CFX_NFS ACTION="PERMISSIONDENY" FOLDER="w:\user\mrsmith\papers\" USERNAME="bob" PERMISSION="RX">




PERMISSIONREVOKE

<CFX_NFS ACTION="PERMISSIONREVOKE" FILE="" or FOLDER="" USERNAME="" or GROUP="">

Removes access or denial of access to the folder for a specific user or group.

<CFX_NFS ACTION="PERMISSIONREVOKE" FOLDER="w:\user\mrsmith\" USERNAME="exemployee">




CACLS

<CFX_NFS ACTION="CACLS" FILE="" or FOLDER="" [QUERY=""]>

This function has little practical use except perhaps for debugging your ACL settings. It is similiar to PERMISSIONS but, unlike the predigested data that function returns, this gives you the rather raw low-level data. Most of it will probably be a complete mystery to you, but if you want to know what the permissions data REALLY looks like -- this is it.

The CACLS field, btw, synthesises all this raw data into a "CACLS" compatible text string (or tries -- it should be close). If you've been using the CACLS command line tool before hand, then this should make you feel right at home.

The query fields returned are:

<CFX_NFS ACTION="CACLS" FOLDER="w:\user\mrsmith" QUERY="s">





top

VERSION HISTORY

[The grassy field]