Link to home
Start Free TrialLog in
Avatar of D J
D JFlag for United States of America

asked on

ColdFusion with Access and Active Directory

We have a ColdFusion page that updates an Access database. I was asked to make provisions to provide the user name to each record that was updated. Maybe a user name field that automatically fills in, when a record is updated?

Can I do this using my existing log in method? (IIS with Active Directory)
Avatar of gaurav05
gaurav05
Flag of India image

Avatar of als315
You can't do it from Access side, but you can try to write CGI.AUTH_USER (full user name with domain)
(no points...)

         provide the user name to each record that was updated

Storing an 'ID" would be better - that is IF your current login method provides one. Reason being if the username changes, you won't be able to associate all of the changes for that user.  

With db table based login systems I create a [user] table:

         UserID | UserName | FirstName | LastName
         1  | jsmith | John | Smith

All key tables have "UpdatedBy" fields that store the "ID" and timestamp of who last updated the records:

               MyTableID | SomeColumn  | UpdatedBy | UpdatedDate
               15 | xxxx data xxxxx |  1 | {date and timestamp  }

To find out who last updated a record OR which records a particular user updated I use a JOIN

             SELECT   t.MyTableID, t.SomeColumn, ...other columns
                            , u.FirstName +' '+ u.LastName AS UpdatedByUser
                            , u.UpdatedDate
             FROM     MyTable t INNER JOIN user u ON u.userID = t.UpdatedBy
             WHERE  .... conditions ....
Avatar of D J

ASKER

Does anyone have a  code sample to obtain the user name and put it in the table with a time stamp?

Should I only use ColdFusion for the authentication or AD?
Which is more secure?
SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of D J

ASKER

IIS 7 is currently managing log in's with AD.
I.E. there isn't any C.F. code for logging in.

Can I obtain the user identity with out using ColdFusion log in code?
@als315 suggested how to do that with CGI variables above.  I'm really rusty w/AD so I'll leave the AD advice to others :)
(Posting comment here, so as not to discourage somebody else from answering your other question...)

I saw an EE thread that mentioned GetAuthUser() can come up blank when anonymous access is enabled. Might be your problem.
Avatar of D J

ASKER

I have the user name and date with time inserting into the table successfully with adding the following code. I'm not using a session variable and need advice if I should alter my code to accommodate one.

Please advise.

<cfset userid =  #GetAuthUser()#>
<cfset updatedt = #now()#>

<cfinput name="updatedt_#currentRow#" type="hidden" value="#now()#" size="15">
<cfinput name="userid_#currentRow#" type="hidden" value="#updateby#" size="15">

<cfset variables.updatedt   = FORM["updatedt_"& counter]>
<cfset variables.updateby   = FORM["userid_"& counter]>

 UPDATEBY =  <cfqueryparam value="#variables.userID#" cfsqltype="cf_sql_varchar">,
 UPDATEDT =  <cfqueryparam value="#variables.updateDT#" cfsqltype="CF_SQL_TIMESTAMP">cfsqltype="CF_SQL_TIMESTAMP">
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of D J

ASKER

Thanks _agx_!