|
The sc_ldap_login macro is responsible for establishing the connection with the LDAP (Lightweight Directory Access Protocol) server, enabling connections to Active Directory (AD). It also defines the behavior of other LDAP macros through the $library parameter, which specifies the library to be used (LdapRecord or adLdap).
Syntax
sc_ldap_login($server, $version = '', $user = '', $password = '', $dn = '', $group = '', $port, $library);
Parameters
| Parameter |
Description |
$server |
IP address or hostname of the LDAP server. |
$version |
LDAP protocol version to be used (example: 3). If left empty, the server's default version will be used. |
$user |
Username for LDAP authentication. It must be in the format expected by the server, such as cn=admin,dc=company,dc=com or user@company.com. |
$password |
Password of the user used for LDAP login. |
$dn |
Distinguished Name (DN) that defines the search point for users. Example: "dc=company,dc=com". |
$group |
Optionally, a group can be specified to check the user's association. |
$port |
Port used to connect to the LDAP server (389 for standard connections and 636 for secure SSL connections). |
$library |
This parameter defines which library will be used for the LDAP connection.
- If the value
2 is provided, the macro will use the new library (LdapRecord), available from version 9.12 of Scriptcase.
- If the parameter is not provided, the macro will continue using the legacy library (
adLdap).
This configuration allows older projects to continue functioning without modifications, while new implementations can benefit from the enhanced compatibility and security of LdapRecord.
|
Example Usage
$server = "ldap.myserver.com";
$version = "3";
$user = "cn=admin,dc=company,dc=com";
$password = "password123";
$dn = "dc=company,dc=com";
$group = "";
$port = 389;
$library = 2;
sc_ldap_login($server, $version, $user, $password, $dn, $group, $port, $library);
Expected Return
Array
(
[0] => Array
(
[sn] => Array
(
[count] => 1
[0] => Newton
)
[0] => sn
[objectclass] => Array
(
[count] => 4
[0] => inetOrgPerson
[1] => organizationalPerson
[2] => person
[3] => top
)
[1] => objectclass
[uid] => Array
(
[count] => 1
[0] => newton
)
[2] => uid
[mail] => Array
(
[count] => 1
[0] => newton@ldap.forumsys.com
)
[3] => mail
[cn] => Array
(
[count] => 1
[0] => Isaac Newton
)
[4] => cn
[count] => 5
[dn] => uid=newton,dc=example,dc=com
)
)
|