OP Enter password

4D - Documentation   Français   English   German   4D Open for 4D, Command Theme List   4D Open for 4D, Command Alphabetical List   Back   Previous   Next

version 1.5


OP Enter password (userNames; userName; userPassword) Longint

ParameterTypeDescription
userNamesArray or StringList of user names (or empty string)
userNameStringSelected (or entered) user name
userPasswordStringEntered password
Function resultLongintError code result for the function

Description

OP Enter password allows you to display the 4th Dimension password dialog boxes so that users can select or enter a name as well as a password.

This routine only displays the 4th Dimension password dialog box. It does not check the users or their passwords in the databases. To do so, use the OP Open connection routine.

userName is the user name that was either entered or selected depending on the dialog box displayed. In 4th Dimension, the maximum length for a user name is 30 characters.

userPassword is the password entered by the user. In 4th Dimension, the maximum length for a password is 15 characters.

If userNames is a non-empty array of type Alpha or Text, the following dialog box appears:

If userNames is an empty array, the following dialog box appears:

Error Codes

If the user clicked the OK or Connect button, OP Enter password returns 0. Otherwise, this function returns one of the following errors:

Error CodeDescription
10147The user clicked Cancel in the Enter password dialog box.
10154This command cannot be executed right now.

Example

This example stores the user name and password in the application preference table. It allows for automatic login at any time.

   ` Method GetUserPasswd
   C_LONGINT ($errcode)
   ARRAY TEXT (arUserNames;0)
   ARRAY DATE (arLastLog;0)
   ARRAY INTEGER (arUserConns;0)
   C_STRING (30;vUserName)
   C_STRING (15;vUserPasswd)

   ` Get the list of user names from the remote server
   $errCode := OP Get user list (vConnectID;arUserNames;arLastLog;arUserConns)

   ` Get the user to select his remote name and enter his password
   $errCode := OP Enter password (arUserNames;vUserName;vUserPasswd)

   READ WRITE ([Preferences])
   `Look for an existing UserName preference
   QUERY ([Preferences];[Preferences]Token = "RemoteLoginName")
   If (Records in selection ([Preferences])=0)
      NEW RECORD ([Preferences])
   End if
   [Preferences]Token := "RemoteLoginName"
   [Preferences]Value := vUserName
   SAVE RECORD ([Preferences])
   `Look for an existing UserPassword preference
   QUERY ([Preferences];[Preferences]Token = "RemoteLoginPasswd")
   If (Records in selection ([Preferences])=0)
      NEW RECORD ([Preferences])
   End if
   [Preferences]Token := "RemoteLoginPasswd"
   [Preferences]Value := vUserPasswd
   SAVE RECORD ([Preferences])
   UNLOAD RECORD ([Preferences])

   ARRAY TEXT (arUserNames;0)
   ARRAY DATE (arLastLog;0)
   ARRAY INTEGER (arUserConns;0)

   ` Method OpenRemoteConnection -> connectionID
   
   C_LONGINT (netCompID;$serverID;$connectID)
   C_LONGINT ($0)
   READ ONLY ([Preferences])
   QUERY ([Preferences];[Preferences]Token = "RemoteServerAdress")
   $address := [Preferences]Value
   QUERY ([Preferences];[Preferences]Token = "RemoteServerProtocol")
   $protocol := [Preferences]Value
   QUERY ([Preferences];[Preferences]Token = "RemoteLoginName")
   $userName := [Preferences]Value
   QUERY ([Preferences];[Preferences]Token = "RemoteLoginPasswd")
   $userPasswd := [Preferences]Value

   If ( ($address="") | ($protocol="") | ($userName="") | ($userPasswd="") )
      `Return 'prefs not availbale' error code
      $0 := -1
   Else
      $errCode := LoadNetComp ($protocol;->netCompID)
      If ($errCode = 0)
         ` Turn the adress string into a server entry
         $errCode := OP Find 4D Server (netCompID;$address;serverID)
      End if
      If ($errCode =0)
         ` Open connection with the server
         $errCode := OP Open connection ($servID; $connID; "CustService"; $userName; $userPasswd;
            "OrderEntry")
      End if
      If ($errCode = 0)
         $0 :=$connID
      Else
         $0 := $errCode
      End if
   End if

See Also

OP Open connection.


4D - Documentation   Français   English   German   4D Open for 4D, Command Theme List   4D Open for 4D, Command Alphabetical List   Back   Previous   Next