org.apache.jmeter.protocol.ldap.sampler

## Class LdapExtClient

- java.lang.Object
- - org.apache.jmeter.protocol.ldap.sampler.LdapExtClient

    public class LdapExtClient
    extends Object

Ldap Client class is main class to create ,modify, search and delete all the LDAP functionality available Based on the work of: author T.Elanjchezhiyan(chezhiyan@siptech.co.in)

### Method Summary

All Methods Static Methods Concrete Methods
`static NamingEnumeration<SearchResult>` `compare(DirContext dirContext, String filter, String entrydn)` Filter the data in the ldap directory
`static DirContext` `connect(String host, String port, String rootdn, String username, String password, String connTimeOut, boolean secure, boolean trustAll)` connect to server
`static DirContext` `createTest(DirContext dirContext, Attributes attributes, String string)` Create the entry in the ldap directory for the given string
`static void` `deleteTest(DirContext dirContext, String string)` Delete the attribute from the ldap directory
`static void` `disconnect(DirContext dirContext)` disconnect from the server
`static void` `moddnOp(DirContext dirContext, String ddn, String newdn)` ModDN the data in the ldap directory for the given search base
`static void` `modifyTest(DirContext dirContext, ModificationItem[] mods, String string)` Modify the attribute in the ldap directory for the given string
`static NamingEnumeration<SearchResult>` `searchTest(DirContext dirContext, String searchBase, String searchFilter, int scope, long countlim, int timelim, String[] attrs, boolean retobj, boolean deref)` Filter the data in the ldap directory for the given search base

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### connect

    public static DirContext connect(String host,
                                     String port,
                                     String rootdn,
                                     String username,
                                     String password,
                                     String connTimeOut,
                                     boolean secure,
                                     boolean trustAll)
                              throws NamingException

connect to server

Parameters:
  `host` - name of the server to connect
  `port` - port of the server to connect
  `rootdn` - base of the tree to operate on
  `username` - name of the user to use for binding
  `password` - password to use for binding
  `connTimeOut` - connection timeout for connecting the server see "com.sun.jndi.ldap.connect.timeout"
  `secure` - flag whether ssl should be used
  `trustAll` - flag whether we should trust all certificates
Returns:
  newly created `DirContext`
Throws:
  `NamingException` - when creating the `DirContext` fails

#### disconnect

    public static void disconnect(DirContext dirContext)

disconnect from the server

Parameters:
  `dirContext` - context do disconnect (may be `null`)

#### searchTest

    public static NamingEnumeration<SearchResult> searchTest(DirContext dirContext,
                                                             String searchBase,
                                                             String searchFilter,
                                                             int scope,
                                                             long countlim,
                                                             int timelim,
                                                             String[] attrs,
                                                             boolean retobj,
                                                             boolean deref)
                                                      throws NamingException

Filter the data in the ldap directory for the given search base

Parameters:
  `dirContext` - context to perform the search on
  `searchBase` - base where the search should start
  `searchFilter` - filter this value from the base
  `scope` - scope for search. May be one of `SearchControls.OBJECT_SCOPE`, `SearchControls.ONELEVEL_SCOPE` or `SearchControls.SUBTREE_SCOPE`
  `countlim` - max number of results to get, `0` for all entries
  `timelim` - max time to wait for entries (in milliseconds), `0` for unlimited time
  `attrs` - list of attributes to return. If `null` all attributes will be returned. If empty, none will be returned
  `retobj` - flag whether the objects should be returned
  `deref` - flag whether objects should be dereferenced
Returns:
  result of the search
Throws:
  `NamingException` - when searching fails

#### compare

    public static NamingEnumeration<SearchResult> compare(DirContext dirContext,
                                                          String filter,
                                                          String entrydn)
                                                   throws NamingException

Filter the data in the ldap directory

Parameters:
  `dirContext` - the context to operate on
  `filter` - filter this value from the base
  `entrydn` - distinguished name of entry to compare
Returns:
  result of the search
Throws:
  `NamingException` - when searching fails

#### moddnOp

    public static void moddnOp(DirContext dirContext,
                               String ddn,
                               String newdn)
                        throws NamingException

ModDN the data in the ldap directory for the given search base

Parameters:
  `dirContext` - context to operate on
  `ddn` - distinguished name of object to rename
  `newdn` - new distinguished name of object
Throws:
  `NamingException` - when renaming fails

#### modifyTest

    public static void modifyTest(DirContext dirContext,
                                  ModificationItem[] mods,
                                  String string)
                           throws NamingException

Modify the attribute in the ldap directory for the given string

Parameters:
  `dirContext` - context to operate on
  `mods` - list of all the `ModificationItem`s to apply on `string`
  `string` - distinguished name of the object to modify
Throws:
  `NamingException` - when modification fails

#### createTest

    public static DirContext createTest(DirContext dirContext,
                                        Attributes attributes,
                                        String string)
                                 throws NamingException

Create the entry in the ldap directory for the given string

Parameters:
  `dirContext` - context to operate on
  `attributes` - add all the attributes and values from the attributes object
  `string` - distinguished name of the subcontext to create
Returns:
  newly created subcontext
Throws:
  `NamingException` - when creating subcontext fails

#### deleteTest

    public static void deleteTest(DirContext dirContext,
                                  String string)
                           throws NamingException

Delete the attribute from the ldap directory

Parameters:
  `dirContext` - context to operate on
  `string` - distinguished name of the subcontext to destroy
Throws:
  `NamingException` - when destroying the subcontext fails