Skip to content
QiTASC.com / intaQt Built-ins /
LDAP Built-ins
/ .. /
LDAP Built-ins





LDAP Built-ins

LDAP Built-ins create and execute LDAP commands with a given set of parameters and arguments. Creating an LDAP command is done by specifying:

  • an LDAP server configuration as defined in intaQt's Server.conf file

  • an LDAP method name (for example, search or modify)

  • flags

  • options

  • arguments

  • file arguments

Important! Windows Users need to have OpenLDAP installed on their PC prior to running test cases using LDAP Built-ins.

Configuration

Multiple LDAP Servers can be configured.

Syntax

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
GenericLdap {
    <ldapServerId String> {
        host            = <String>
        uri             = <String>
        port            = <Number>
        protocol        = <Number>
        password        = <String>
        timeoutMillis   = <Number>
        extraOptions    = <String>
    }
}

Parameters

  • ldapServerId - The LDAP Server's name

  • host - The LDAP Server's IP Address

  • uri - The LDAP Server's uniform resource identifier

  • port - The port number the LDAP server listens on

  • protocolVersion (optional) - Defines the LDAP protocol version to be used

    • Can be 2 or 3, with a default of 3
  • password - The password for accessing the LDAP service

  • timeoutMillis - Defines the timeout for communication with the LDAP Server in milliseconds

    • Default is set to 5000
  • extraOptions - A raw option string that is appended to the list of options in the LDAP command

    • This should only contain extra options that are specific to the LDAP service being used

Note: Only one of host or URI must be specified.

Example

1
2
3
4
5
6
7
8
9
GenericLdap {
    "myLdap" {
        host            = "192.168.l.l"
        port            = 389
        protocol        = 3
        password        = "qitasc"
        timeoutMillis   = 30000
    }
}

Using LDAP Built-ins in a Stepdef

LDAP commands are built by concatenating the builder methods with decimal point separators and executed by calling execute or tryExecute. The return value is a string that contains the LDAP command's output.

Syntax

1
2
3
4
5
6
cmd := Ldap.server(<nameOfServer String>)
 .search()
 .arg(<LDAPArgument String>)
 .binddn(<distinguishedName String>)
 .searchBase(<searchBase String>)
 result := cmd.execute()

Parameters

  • nameOfServer - The LDAP Server's name

  • LdapArgument - An argument that defines the query

    • This will be specific to the LDAP Server being tested
  • distinguishedName - The credential used to authenticate against an LDAP

  • searchBase - Defines where in the directory the LDAP search starts from

More information about terms used in LDAP searches is available from the OpenLDAP Website.

Example 1

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
cmd := Ldap.server("myLdap")
 .search()
 .arg("defid=" + param)
 .arg("datagroupid")
 .binddn("uid=username,ou=applications,ou=admin,ou=mmo,c=de,o=company")
 .searchBase("ou=subscriber,ou=MMO,c=at,o=company")
 result := cmd.execute()
 ```

**Example 2**
```go
func search(systemType, subscriber)
        system := getReadHost(subscriber, systemType)
        msisdn := PhoneProfilesHandling.getMsisdnFromObject(subscriber)
        LOG.debug(msisdn)
        return Ldap.server(system)
                .search()
                .binddn(UserRepo.dn())
                .searchBase(UserRepo.searchb())
                .arg("id=" + msisdn)
                .tryExecute()
end

Available Builder Methods

Syntax Description
arg(<String>) Defines a string argument.
addToFile(<String>) Defines an argument that is written to a file prior to executing the LDAP command. The filename is passed to the LDAP command using the -f option.
binddn(<String>) Defines a distinguished name.
debug() Adds the -n flag that only shows what would be done without performing the LDAP command.
raw(<flag String>, <value String>) Adds the option given in flag with the value defined by value to the LDAP command. This can also be used to append a standalone flag with raw("<flag>", "").
searchBase(<String>) This is only available for the search command and defines the starting point of the search.
scope(<String>) This is only available for the search command and specifies the scope of the search.
addEntries() This is only available for the modify command and specifies that entries are added instead of being modified.
tryExecute() Catches any exception during execution and returns a string result.
execute() Executes the LDAP command and returns a string result.