LdapConnect(connName, hostName, user, password);
connName
A name you specify which will be used in all the following LDAP functions to identify which server they will access.hostName
The name of the server to which you want to establish a connection. The default port is 389, but can be overridden using the host:port syntax in the host name.user
password
You do not need to use LdapConnect for every scripting function. Once the server connection is established, it will only be closed when you call the LdapDisconnect function, or when the job completes.To establish an LDAP connection that is not closed when the job completes, see LdapConnectPersistent.Leaving the user and password fields blank implies an anonymous logon. The StreamServer will authenticate with anonymous rights (usually a limited read-only authentication).You can use the LDAPConnectTimeout keyword to specify a time-out for connecting to the Directory Server. If the connection is not established within the time-out period an error is logged and the LDAPConnect function returns its standard failure code. If no time-out value is specified, the default value 15 seconds is used.To specify a connection time-out, enter the following keyword to the Platform:
LDAPConnectTimeout <n>
where n is the number of seconds.
Note: The LDAP connection function attempts to open a socket to the server. If the Directory Server cannot be contacted, the time-out will revert to the underlying TCP time-out.The LDAPConnectTimeout keyword does not work with the LDAPConnectSSL or LDAPConnectSSLCCA functions.
1 -1 $err = -1;$myphotofile = "c:\myphotos\myphoto.jpg"; // myPhoto$myuid = "sab01";LdapConnect("my_conn", "localhost", "cn=directory manager","streamserve"); // Connect to the ldap server$results=ldapFind("my_conn","ou=StreamServe Users, dc=streamserve,dc=com", "uid=" +$myuid); // Find my entry matches$myentry=ldapGetEntry($results, 0); // Get the first entry match$err = LdapAddAttrBinaryValue($myentry,"photo", $myphotofile);// Add the jpg file to the photo attributelog(1,"ldapaddattr errorcode=" +$err);$err = LdapUpdateEntry($myentry); // update the attributelog(1,"ldapupdateentry errorcode=" +$err);LdapDisConnect("my_conn"); //DisconnectIn this example, a connection is established to the LDAP server on the local machine (localhost). The connection is given the name con and attaches to the default port (389).
Note: The common name (cn) consists of the first and last names of the user.
OpenText StreamServe 5.6 | Updated: 2013-03-01 |