6 34 3 C Example

LANSA Open Guide

6.34.3 C# Example

  

namespace LansaOpenNative

{

   class LansaOpen

   {

      [DllImport( "lcoew32.dll", CharSet = CharSet.Ansi )]

      public static extern int LceGetIBMiSignon(

         StringBuilder                             server,

         int                                       mapperPort,

         int                                       sslRequired,

         StringBuilder                             userId,

         StringBuilder                             password,

         int                                       encryptPassword,

         StringBuilder                             returnCode,

         StringBuilder                             expiryDate );

   }

}

 

private void LOpenSample()

{

   String strServer = "myuser";

   int iMapperPort = 0;

   bool fSSLRequired = false;

   String strUserid = "myuser";

   String strPassword = "mypasswd";

   bool fEncryptPassword = true;

   StringBuilder strReturnCode = new StringBuilder( 3 );

   StringBuilder strExpiryDate = new StringBuilder( 20 );

   bool rc;

 

   rc = LansaOpen.LceGetIBMiSignon(

      new StringBuilder( strServer ),

      iMapperPort,

      ( fSSLRequired ? 1 : 0 ),

      new StringBuilder( strUserid ),

      new StringBuilder( strPassword ),

      ( fEncryptPassword ? 1 : 0 ),

      strReturnCode,

      strExpiryDate );

 

   if ( rc )

   {

      if ( strReturnCode.ToString() == "OK" )

      {

         txtStatusField.Text = String.Format( "Signon details successfully retrieved. Expiry Date: {0}", strExpiryDate );

      }

      else

      {

         txtStatusField.Text = String.Format( "The request to the server has failed with return code: {0}", strReturnCode );

      }

   }

   else

   {

      txtStatusField.Text = "The function failed to run successfully";

   }

}