Search in sources :

Example 6 with LDAPConnection

use of org.pentaho.di.trans.steps.ldapinput.LDAPConnection in project pentaho-kettle by pentaho.

the class LDAPOutputDialog method test.

private void test() {
    LDAPConnection connection = null;
    try {
        LDAPOutputMeta meta = new LDAPOutputMeta();
        getInfo(meta);
        // Defined a LDAP connection
        connection = new LDAPConnection(log, transMeta, meta, null);
        // connect...
        if (wusingAuthentication.getSelection()) {
            connection.connect(transMeta.environmentSubstitute(meta.getUserName()), Encr.decryptPasswordOptionallyEncrypted(transMeta.environmentSubstitute(meta.getPassword())));
        } else {
            connection.connect();
        }
        // We are successfully connected
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
        mb.setMessage(BaseMessages.getString(PKG, "LDAPOutputDialog.Connected.OK") + Const.CR);
        mb.setText(BaseMessages.getString(PKG, "LDAPOutputDialog.Connected.Title.Ok"));
        mb.open();
    } catch (Exception e) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
        mb.setMessage(BaseMessages.getString(PKG, "LDAPOutputDialog.Connected.NOK", e.getMessage()));
        mb.setText(BaseMessages.getString(PKG, "LDAPOutputDialog.Connected.Title.Error"));
        mb.open();
    } finally {
        if (connection != null) {
            // Disconnect ...
            try {
                connection.close();
            } catch (Exception e) {
            /* Ignore */
            }
        }
    }
}
Also used : LDAPOutputMeta(org.pentaho.di.trans.steps.ldapoutput.LDAPOutputMeta) LDAPConnection(org.pentaho.di.trans.steps.ldapinput.LDAPConnection) KettleException(org.pentaho.di.core.exception.KettleException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

KettleException (org.pentaho.di.core.exception.KettleException)6 LDAPConnection (org.pentaho.di.trans.steps.ldapinput.LDAPConnection)6 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)3 MessageBox (org.eclipse.swt.widgets.MessageBox)2 TableItem (org.eclipse.swt.widgets.TableItem)2 RowMeta (org.pentaho.di.core.row.RowMeta)2 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)2 LDAPInputMeta (org.pentaho.di.trans.steps.ldapinput.LDAPInputMeta)2 LDAPOutputMeta (org.pentaho.di.trans.steps.ldapoutput.LDAPOutputMeta)2 ArrayList (java.util.ArrayList)1 SourceToTargetMapping (org.pentaho.di.core.SourceToTargetMapping)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 EnterMappingDialog (org.pentaho.di.ui.core.dialog.EnterMappingDialog)1