This topic is locked

Active Directory User Name

11/1/2006 7:19:59 PM
ASPRunnerPro General questions
T
tgunther author

I figured out how to grab the domain and user name from active directory setting the default value of my user column to:

Request.ServerVariables("LOGON_USER")

and it works fine on an add page. It grabs the user name and domain name so that I know exactly who was logged in and who added a record. The next step that I need to figure out is when an edit is made to a record what user made the edit, currently when I make an edit the user does not changed, by the way this is a read only field. Can you help?

Thanks,

Tim

Sergey Kornilov admin 11/1/2006

Tim,
you can use BeforeEdit Event and the follwing code:

dict("UpdatedBy") = Request.ServerVariables("LOGON_USER")
T
tgunther author 11/2/2006

Sergey,

Thank you for the response unfortunately I was unsuccessful in implementing this code into the before edit event on the the edit page. Here is the code that I attempted to add to the edit page on the before record updated section in ASP Runner:

Function BeforeEdit(dict, where)

dict("UpdatedBy") = Request.ServerVariables("LOGON_USER")

BeforeEdit = True

End Function


I also tried:

Function BeforeEdit(dict, where)

dict("Modifier") = Request.ServerVariables("LOGON_USER")

BeforeEdit = True

End Function



Because Modifier is the name of the field that I want the user information to be changed in. Thank you for your help and I am sorry for all of the questions, I am new to ASP.

Thanks,

Tim

C
clig 11/16/2006

Tim,

you can use BeforeEdit Event and the follwing code:

dict("UpdatedBy") = Request.ServerVariables("LOGON_USER")


I use this type of event commonly:
Function BeforeEdit(dict, where)
' Parameters:

' dict - Scripting.Dictionary object.

' Each field on the Edit form represented as 'Field name'-'Field value' pair

' where - string with WHERE clause pointing to record to be edited
'** Custom code ****

' put your custom code here
dict("Last Modified") = strUserID & " - " & Now()
BeforeEdit = True
' set BeforeEdit to True if you like to proceed with editing this record

' set it to False in other case
End Function

  • I get strUserID from aspfunction page - placing the code just before:
    Dim strUserID

    strUserID = Request.ServerVariables("AUTH_USER")

    strUserID = Mid(strUserID,(instr(1,strUserID,"\")+1),len(strUserID))
    ' returns field's default value

    function GetDefaultValue(strField)
  • dict("column name") = actual name of column in db
  • I suppose you could just as easily get strUserID from before edit too - just used to 3.x - In 4.1 I don't think we can do this anymore??? Need to use the events?

Sergey Kornilov admin 11/16/2006

cliq,
you have several options in ASPRunnerPro 4.1

  1. Put this code to include/header.asp file
  2. Use common event like LoginOnLoad and save value into session variable
  3. (Not recommended) modify dbcommon.asp or commonfunctions.asp in C:\Program files\ASPRunnerPro4.1\source\include directory to this your code.

C
clig 11/17/2006

cliq,

you have several options in ASPRunnerPro 4.1

  1. Put this code to include/header.asp file
  2. Use common event like LoginOnLoad and save value into session variable
  3. (Not recommended) modify dbcommon.asp or commonfunctions.asp in C:\Program files\ASPRunnerPro4.1\source\include directory to this your code.


Thank you sir