Skip to content

ExecuteLdapQuery

Executes a search on the specified rootDN or host and returns the array of LDAP entries.

1
$Domain.ExecuteLdapQuery(rootDnOrHost: string, attributes?: string, filter?: string, username?: string, password?: string):Array<LdapEntry>

Parameters

string rootDnOrHost
    The root DN (Distinguished Name) or host name to search.

string attributes optional
    The attributes to return, separated by ;. Optional.

string filter optional
    The filter for the search. Optional.

string username optional
    The username to authenticate with. Optional.

string password optional
    The password to authenticate with. Optional.

Returns

An array of LDAP entries. Each entry has a property for each returned attribute.

Remarks

Before calling this method, LDAP connection settings must be configured in the application settings.

Examples

Read users from a directory

1
2
3
4
5
6
7
8
var entries = $Domain.ExecuteLdapQuery('dc=example,dc=com', 'cn;mail', '(&(objectClass=user)(mail=*))');

entries.forEach(function (entry) {
    $Xml.AppendChild('Users/User', function (user) {
        user.SetValue('Name', entry['cn']);
        user.SetValue('Email', entry['mail']);
    });
});

See Also