Rob's TIMSS Blog

My discoveries and ramblings of TIMSS/Personify.

Tuesday, April 18, 2006

Extender Scripting: Field Level Security

So tab level security isn't secure enough for you. You can use the UserId & Enabled values to see who the current user is and enable or disable fields for them.

If Myform.AppContext.UserId ="STARTUP" then
Myform.getformControlByName("cboType").Enabled="True"
Else
Myform.getformControlByName("cboType").Enabled="False"
End If


The code above will have the combo box enabled only for the STARTUP user.

To expand on this, you could write an SQL statement to see if the user is a member of a particular security group:


dim strSQL as String
dim dsGroup as Object


strSQL = "select user_group from sec_group_member "
strSQL = strSQL & "where user_group='ADMIN' and user_id='"
strSQL = strSQL & Myform.AppContext.UserId &"'"
dsGroup=MyForm.ScriptingGetDataSetWithSQL(strSQL, "SEC_GROUP_MEMBER")

If Not dsGroup Is Nothing and not dsGroup.Tables(0).Rows.Count=0 then
Myform.getformControlByName("cboType").Enabled="True"
Else
Myform.getformControlByName("cboType").Enabled="False"
End If

So if the SQL returns a value for the group ADMIN and the current user, then we enable the control, otherwise we disable it.

Applies to: TIMSS6

0 Comments:

Post a Comment

<< Home