# SearchObjects

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.LDAP>

{% tabs %}
{% tab title="Parameter: Input" %}

| Name                                      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| SearchBase : `String`                     | <p>The search base parameter specifies the DN of the entry where you want to begin the search.</p><p>If you want the search to begin at the tree root pass an empty string.</p><p><br>Default: <code>-</code><br>Example: <code>"ou=users,dc=wimpi,dc=net"</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| Scope : `Scopes`                          | <p>The search scope parameter specifies the depth of the search.</p><p>Possible values:</p><ul><li><code>ScopeBase</code>:</li></ul><p>The search scope parameter specifies the depth of the search.</p><ul><li><code>ScopeOne</code>:</li></ul><p>The search scope parameter specifies the depth of the search.</p><ul><li><code>ScopeSub</code>:</li></ul><p>The search scope parameter specifies the depth of the search.</p><p><br>Default: <code>-</code><br>Example: <code>Scopes.ScopeBase</code></p>                                                                                                                                                                                                                                                                                        |
| Filter : `String`                         | <p>The search filter defines the entries that will be returned by the search. The LDAP search filter grammar is specified in RFC 2254 and 2251. The grammar uses ABNF notation. If you are looking for all employees with a title of engineer, the search filter would be (title=engineer).</p><p><br>Default: <code>-</code><br>Example: <code>(title=engineer)</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                         |
| MsLimit : `Int32`                         | <p>The maximum time in milliseconds to wait for results. The default is 0, which means that there is no maximum time limit.</p><p><br>Default: <code>0</code><br>Example: <code>0</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ServerTimeLimit : `Int32`                 | <p>The maximum time in seconds that the server should spend returning search results. This is a server-enforced limit. The default of 0 means no time limit.</p><p><br>Default: <code>0</code><br>Example: <code>0</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| SearchDereference : `SearchDereference`   | <p>Specifies when aliases should be dereferenced.</p><p>DerefNever, DerefFinding, DerefAlways</p><p>Possible values:</p><ul><li><code>DerefNever</code>:</li></ul><p>Specifies when aliases should be dereferenced.</p><p>DerefNever, DerefFinding, DerefAlways</p><ul><li><code>DerefSearching</code>:</li></ul><p>Specifies when aliases should be dereferenced.</p><p>DerefNever, DerefFinding, DerefAlways</p><ul><li><code>DerefFinding</code>:</li></ul><p>Specifies when aliases should be dereferenced.</p><p>DerefNever, DerefFinding, DerefAlways</p><ul><li><code>DerefAlways</code>:</li></ul><p>Specifies when aliases should be dereferenced.</p><p>DerefNever, DerefFinding, DerefAlways</p><p><br>Default: <code>0</code><br>Example: <code>SearchConstraints.DerefNever</code></p> |
| MaxResults : `Int32`                      | <p>The maximum number of search results to return.</p><p>This acts as a hard limit—regardless of page size or batch size, no more than this number of results will be returned.</p><p>Set to 0 for no limit.</p><p><br>Default: <code>1000</code><br>Example: <code>1000</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| BatchSize : `Int32`                       | <p>This parameter controls the chunk size in which data will be read from the server. This does not affect the output result amount.</p><p><br>Default: <code>100</code><br>Example: <code>1</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| PageSize : `Int32`                        | <p>Controls how many entries are requested from the server in a single page during a paged LDAP search.</p><p>This directly affects how results are fetched from the server.</p><p>If set to 0, paging is disabled and all entries are requested in a single operation (not recommended for large directories).</p><p><br>Default: <code>500</code><br>Example: <code>1</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                  |
| TypesOnly : `Boolean`                     | <p>If true, returns the names but not the values of the attributes found.</p><p>If false, returns the names and values for attributes found.</p><p><br>Default: <code>False</code><br>Example: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ContentEncoding : `ContentEncoding`       | <p>Specifies the encoding of the content.</p><p>Possible values:</p><ul><li><code>UTF8</code>:</li></ul><p>Specifies the encoding of the content.</p><ul><li><code>Default</code>:</li></ul><p>Specifies the encoding of the content.</p><ul><li><code>ASCII</code>:</li></ul><p>Specifies the encoding of the content.</p><ul><li><code>WINDOWS1252</code>:</li></ul><p>Specifies the encoding of the content.</p><ul><li><code>Other</code>:</li></ul><p>Specifies the encoding of the content.</p><p><br>Default: <code>1</code><br>Example: <code>ContentEncoding.UTF8</code></p>                                                                                                                                                                                                               |
| EnableBom : `Boolean`                     | <p>Enable BOM in UTF-8 encoding.</p><p><br>Default: <code>-</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ContentEncodingString : `String`          | <p>Content encoding as string.</p><p><br>Default: <code>-</code><br>Example: <code>windows-1251</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| SearchOnlySpecifiedAttributes : `Boolean` | <p>Determine if only specified attributes should be returned.</p><p>This allows user to specify encoding and type for certain attributes.</p><p><br>Default: <code>True</code><br>Example: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| Attributes : `Attributes[]`               | <p>The names of attributes to retrieve.</p><p><br>Default: <code>-</code><br>Example: <code>new Attributes\[] { new Attributes { Key = "title", ReturnType = ReturnType.String }, new Attributes { Key = "objectGUID", ReturnType = ReturnType.Guid }, new Attributes { Key = "photo", ReturnType = ReturnType.ByteArray } }</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| {% endtab %}                              |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |

{% tab title="Parameter: Connection" %}

| Name                                | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Host : `String`                     | <p>LDAP server host.</p><p>This can be a domain name, LDAP alias, or a Domain Controller FQDN.</p><p><br>Default: <code>-</code><br>Example: <code>emea.company.com</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| Port : `Int32`                      | <p>Port. Value 0 = use LDAP/LDAPS default port which is 389 or 636 depending on (SecureSocketLayer) and (TLS).</p><p><br>Default: <code>0</code><br>Example: <code>389</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| SecureSocketLayer : `Boolean`       | <p>Perform secure operation.</p><p><br>Default: <code>-</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| IgnoreCertificates : `Boolean`      | <p>Ignore server certificates</p><p><br>Default: <code>False</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| TLS : `Boolean`                     | <p>Connection is protected by TLS.</p><p><br>Default: <code>-</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| LDAPProtocolVersion : `LDAPVersion` | <p>Used LDAP protocol version.</p><p>Warning: LDAPv2 is deprecated and has security vulnerabilities. Use LDAPv3 unless absolutely required.</p><p>Possible values:</p><ul><li><code>V2</code>:</li></ul><p>Used LDAP protocol version.</p><p>Warning: LDAPv2 is deprecated and has security vulnerabilities. Use LDAPv3 unless absolutely required.</p><ul><li><code>V3</code>:</li></ul><p>Used LDAP protocol version.</p><p>Warning: LDAPv2 is deprecated and has security vulnerabilities. Use LDAPv3 unless absolutely required.</p><p><br>Default: <code>1</code><br>Example: <code>LDAPVersion.V3</code></p> |
| AnonymousBind : `Boolean`           | <p>If enabled credentials are not used to create a bind to the LDAP server.</p><p><br>Default: <code>False</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| User : `String`                     | <p>User.</p><p><br>Default: <code>-</code><br>Example: <code>Foo</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| 🗝Password : `String`               | <p>Password.</p><p><br>Default: <code>-</code><br>Example: <code>Bar123</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ThrowExceptionOnError : `Boolean`   | <p>If enabled Task throws an exception when LDAP error happens.</p><p><br>Default: <code>False</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| {% endtab %}                        |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |

{% tab title="Result: Result" %}

| Name                                | Description                                                                                                                                        |
| ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| Success : `Boolean`                 | <p>Search completed.<br>Example: <code>true</code></p>                                                                                             |
| Error : `String`                    | <p>LDAP Error message.<br>Example: <code>Entry Already Exists</code></p>                                                                           |
| SearchResult : `List<SearchResult>` | <p>Results.<br>Example: <code>{ AttributeSet { Key = "sn", Value = "Bar" }, DistinguishedName = "CN=Foo Bar,ou=users,dc=wimpi,dc=net" }</code></p> |
| {% endtab %}                        |                                                                                                                                                    |

{% tab title="Changelog" %}

## Changelog

### \[4.2.0] - 2026-02-03

#### Changed

* Improved documentation for Host parameter usage

### \[4.1.0] - 2025-06-17

#### Added

* Improved LDAP error handling by validating bind status and checking search response codes.
* Block negative values for MsLimit

### \[4.0.0] - 2025-04-04

#### Added

* \[Breaking] - Parameter for PageSize to control how many entries are fetched per page during an LDAP search.
* Default value for the new parameter:
  * PageSize: 500
* If you want the Task to work exactly as before (non-paged search), set PageSize = 0.
* Default paging behavior (PageSize = 500) may improve performance on large result sets, but changes how results are retrieved from the server.

### \[3.1.0] - 2025-04-01

#### Added

* Added example values for new parameters.

### \[3.0.0] - 2025-03-17

#### Added

\[Breaking]

* Updated to version 3.0.0 with enhanced LDAP search capabilities.
* Added support for selecting custom attributes, allowing users to receive attribute values as either text, byte array or Guid.
* Introduced new encoding options�including BOM support and various encoding choices�for improved handling of search results.
* Enabled an option to return only specified attributes, enhancing control over the output.
* Added functionality to handle photo attributes in LDAP entries.
* Enhanced flexibility in specifying content encoding for search results.
* New methods and properties for improved search input handling and attribute retrieval.
* Changed the Result object to be a dictionary of string, object to allow for more flexibility in the output.

#### Upgrade Instructions

* Task's default values for new and changed parameters are configured to match the previous behavior. If you want to use the new functionality, you will need to update the parameters accordingly.
  * 'SearchOnlySpecifiedAttributes' parameter defaults to true which was the previous behavior. If you just want to specify certain attributes' types, set it to false. If not enabled the non specified attributes will be returned as string typed.
  * 'ContentEncoding' parameter defaults to the Agent's default encoding. If you want to use a different encoding, set it to the desired encoding.
* Task's output has been updated to reflect the new Result object structure. This will have impact on how the Result object can be manipulated in other elements.

### \[2.1.0] - 2025-01-02

#### Fixed

* Fixed issue with AttributeSet not having all values that were returned from LDAP search.

### \[2.0.0] - 2024-11-06

#### Added

* \[Breaking] Parameter for AnonymousBind to enable to connect without credentials.
* \[Breaking] Parameter for LDAPProtocolVersion to choose what LDAP version should be used.
* Default values for new parameters are:
  * AnonymousBind: false
  * LDAPProtocolVersion: 3
* Use the default parameters if you want the Task to work as before.
* Check for Filter parameter that it's not empty and set null to it if it is so that the library sets objectClass=\* as the filter.

### \[1.0.0] - 2022-10-03

#### Added

* Initial implementation
  {% endtab %}
  {% endtabs %}
