Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

User "Enabled"- Problem

 Post Reply Post Reply
Author
Matthias Letzel View Drop Down
New Member
New Member
Avatar

Joined: 19 Apr 2013
Posts: 9
Post Options Post Options   Quote Matthias Letzel Quote  Post ReplyReply Direct Link To This Post Topic: User "Enabled"- Problem
    Posted: 19 Apr 2013 at 9:16am
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
Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8411
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 19 Apr 2013 at 9:54am
Yes, for databases that do not have boolean fields, using 0 & 1 and map on integer fields should make this work.
Back to Top
Matthias Letzel View Drop Down
New Member
New Member
Avatar

Joined: 19 Apr 2013
Posts: 9
Post Options Post Options   Quote Matthias Letzel Quote  Post ReplyReply Direct Link To This Post Posted: 19 Apr 2013 at 10:06am
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;
Back to Top
Kinnunen Jari View Drop Down
New Member
New Member
Avatar

Joined: 13 Apr 2012
Posts: 11
Post Options Post Options   Quote Kinnunen Jari Quote  Post ReplyReply Direct Link To This Post Posted: 19 Jul 2013 at 11:37am
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.

Back to Top
Kinnunen Jari View Drop Down
New Member
New Member
Avatar

Joined: 13 Apr 2012
Posts: 11
Post Options Post Options   Quote Kinnunen Jari Quote  Post ReplyReply Direct Link To This Post Posted: 20 Jul 2013 at 6:48am
Changing the field type of the enabled field to varchar with appropriate length seems to repair that problem... 
Back to Top
Kinnunen Jari View Drop Down
New Member
New Member
Avatar

Joined: 13 Apr 2012
Posts: 11
Post Options Post Options   Quote Kinnunen Jari Quote  Post ReplyReply Direct Link To This Post Posted: 20 Jul 2013 at 8:33am
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

Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8411
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 22 Jul 2013 at 4:57am
We have send an incremental source update by email. Please retest with this update.
Back to Top
Kinnunen Jari View Drop Down
New Member
New Member
Avatar

Joined: 13 Apr 2012
Posts: 11
Post Options Post Options   Quote Kinnunen Jari Quote  Post ReplyReply Direct Link To This Post Posted: 22 Jul 2013 at 1:13pm
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.

Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8411
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 22 Jul 2013 at 2:36pm
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.
Back to Top
Kinnunen Jari View Drop Down
New Member
New Member
Avatar

Joined: 13 Apr 2012
Posts: 11
Post Options Post Options   Quote Kinnunen Jari Quote  Post ReplyReply Direct Link To This Post Posted: 22 Jul 2013 at 4:15pm
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
Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8411
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 22 Jul 2013 at 4:19pm
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.
Back to Top
Kinnunen Jari View Drop Down
New Member
New Member
Avatar

Joined: 13 Apr 2012
Posts: 11
Post Options Post Options   Quote Kinnunen Jari Quote  Post ReplyReply Direct Link To This Post Posted: 22 Jul 2013 at 5:08pm
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

Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8411
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 28 Jul 2013 at 3:29am
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.
Back to Top
Kinnunen Jari View Drop Down
New Member
New Member
Avatar

Joined: 13 Apr 2012
Posts: 11
Post Options Post Options   Quote Kinnunen Jari Quote  Post ReplyReply Direct Link To This Post Posted: 28 Jul 2013 at 11:35am
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
Back to Top
Bruno Fierens View Drop Down
TMS Support
TMS Support
Avatar

Joined: 11 May 2010
Posts: 8411
Post Options Post Options   Quote Bruno Fierens Quote  Post ReplyReply Direct Link To This Post Posted: 29 Jul 2013 at 5:15am
We'll check if we can build-in that solution.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down