Search in sources :

Example 1 with LDAPOutputMeta

use of org.pentaho.di.trans.steps.ldapoutput.LDAPOutputMeta in project pentaho-kettle by pentaho.

the class LDAPOutputDialog method getLDAPFields.

public RowMetaInterface getLDAPFields() throws KettleException {
    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()) {
            String username = transMeta.environmentSubstitute(wUserName.getText());
            String password = Encr.decryptPasswordOptionallyEncrypted(transMeta.environmentSubstitute(wPassword.getText()));
            connection.connect(username, password);
        } else {
            connection.connect();
        }
        return connection.getFields(transMeta.environmentSubstitute(wBaseDN.getText()));
    } finally {
        if (connection != null) {
            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)

Example 2 with LDAPOutputMeta

use of org.pentaho.di.trans.steps.ldapoutput.LDAPOutputMeta 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)2 LDAPConnection (org.pentaho.di.trans.steps.ldapinput.LDAPConnection)2 LDAPOutputMeta (org.pentaho.di.trans.steps.ldapoutput.LDAPOutputMeta)2 MessageBox (org.eclipse.swt.widgets.MessageBox)1