LdapConnectPersistent(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 LdapConnectPersistent for every scripting function. Once the server connection is established, it will only be closed when you call the LdapDisconnect function.Leaving the user and password fields blank implies an anonymous logon. The StreamServer will authenticate with anonymous rights (usually a limited read-only authentication).The LDAPConnectPersistent function is affected by the a custom setting on the Platform. The LDAPConnectTimeout keyword allows you to specify a timeout limit, in seconds, to be used when connecting to a Directory Server. If the connection is not completed within the timeout period an error is logged and the script function returns its standard failure code.The syntax for the LDAPConnectTimeout keyword is
LDAPConnectTimeout <n>
where n is the number of seconds..
Note: The LDAP library function for connecting attempts to open a socket to the server before the timeout value comes into play. This means that if the server cannot be contacted, the timeout will revert to the underlying TCP timeout.
1 -1 $err = -1;$myphotofile = "c:\myphotos\myphoto.jpg"; // myPhoto$myuid = "sab01";LdapConnectPersistent("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 |