User "Enabled"- Problem

Hello,

there is a problem when using databases without boolean fields (like Firebird) for the SecurityManager.
Alternatives may be using fields like int or char. But doing so will cause errors due to the properties settings in the
the uIWEditUserForm.pas and uEditUserForm.pas for enabled-checkbox. On both forms the ValueChecked are set to "true" and ValueUnchecked to "false", which will cause the set string values into the integer or char field in the database. Changing them to "1" and "0" instead seems to work.

Any comments?

Best regards
Matthias

Yes, for databases that do not have boolean fields, using 0 & 1 and map on integer fields should make this work.

I also had to change one line in the code because a disabled user was not noticed even if the value was "0"  (uSecControl.pas):

if Fld.DataType = ftBoolean then
      begin
        if not Fld.AsBoolean then
        begin
          TriggerDisabledLoginEvent(Username);
          Exit;
        end;
      end
      else
      begin // in case database does not support boolean fields
        if (Fld.AsInteger <> 1) then       //  this line did not work:  (not Fld.AsInteger = 1)
        begin
          TriggerDisabledLoginEvent(Username);
          Exit;
        end;

      end;

Hi
I have just installed IWsecsystem (5.3.0.0). The Enabled -field is now integer in my Firebird 2.1.5 database and the useradmin-dialog opens nicely from uilSecurityManager-component (smallint is not a good choice...). I can edit, create and delete users. But if I check or uncheck the enabled-field in "Edit User"-form and press OK- or Cancel-button I get an errormessage :
" 'True' is not a valid integer value for field 'ENABLED'. " or " 'False' is not a valid integer value for field 'ENABLED'. "
The code change from the post of Matthias Letzel seems not to be pulished. Anyway it does not have any effect to this behaviour.

Changing the field type of the enabled field to varchar with appropriate length seems to repair that problem... 

But now when the type is varchar and value of the enabled field is saved as string, gives normal login an error:

 " 'True' is not a valid integer' "
It looks like if the Enabled field type is integer any value behaves like True ... just like discussion above describes.

My uisecuritymanager component version is 2.4.2.2. I have installed the module using instructions in Install.txt with one exception instead of "msbuild IW14TSSUIDXE4.dproj" I use "msbuild IW14TSSUIDXE4UPD.dproj" because the first one didn't work and my Intraweb version is 14.0.12

We have send an incremental source update by email. Please retest with this update.

Here is my test result
if Enabled field is varchar(11)
-  with  uIWSecDlgForm field value in database updates 'false' or 'true'
-  with uiIWSecurityManager  field value in database updates is 'False' or 'True' 
Both dialogs shows enabled right way flagged or empty
However Login works only with Enabled field value '1' all other functions like disabled
Dialogs shows enabled with number values ('0' or '1')  always empty

if Enabled field is integer 
-  with  uIWSecDlgForm field value change results error 
                                                 The following exception occured  
                                                  cbEnabled: 'false' is not a valid integer value for field 'ENABLED' 
   false or true depends field value 0 or 1 in database 
   field on dialog is allways empty
-  with uiIWSecurityManager  field value change results error  
                                                  " 'True' is not a valid integer value for field 'ENABLED'. " 
   initial outlook of enabled field is filled
   field value ids flagged or not and error message depends on that visual effect (database is not touched at all) 
   Login works like expected 1 let's you in other values not.

Now when I have made such testing I wonder the login mechanism.  It looks like database table read happens only at the beginning of session at least concerning enabled field. My humble opinion is  that when ever  user have to do login it should be checked if user is f.ex enabled or not.

what does your ENABLED field.DataType return?

It is expected that when it is a string, the value returned is either ftString or ftWideString and in that case the values are T or F. When it is an integer, it should return ftInteger and the expected values are 0 or 1 and finally, when it returns ftBoolean, we use field.AsBoolean to store the enabled value.

Each time a login happens, the enabled/visible settings are reapplied.

With this kind of if clause


 with DMUser.taUserTable.fieldbyname('ENABLED') do
  if DataType=ftInteger then
    WebApplication.ShowMessage('ENABLED = ftInteger' +'  ' + AsString);

I got messagebox " ENABLED = ftInteger  0 " which is the first records enabled value I suppose

With the update sent, condition Enabled = true is saved as 1 in an integer field and false is stored as 0.
I cannot see any problem with this here.

If a problem persists, contact us by email with some sample source app with which we can reproduce this.

If I change the properties ValueChecked and ValueUnchecked in the uIWEditUserForm 


ValueChecked from 'true' to 1
ValueUnchecked from 'false' to 0

Edit User -form works without problem

That is a solution for a DB that doesn't have a boolean field and maps the boolean to an integer field, but this solution will not work when a real boolean field is used.
So, for DBs that don't have a boolean field available, this change can indeed be done.

yes, short way solution only for me ...

I send an email couple days ago which have version of  uIWSecDlgForm containing an update of ValueChecked and ValueUnchecked properties of cbEnabled of uIWEditUserForms depending on Enabled field type. 

I managed answer your response with an other email with a taught you red the first one. I wondered how poor my english is before I understood you haven't seen that yet

We'll check if we can build-in that solution.