LDAP protocol example script
All LDAP functions come in pairs—one for global sessions and one where you can indicate a specific session. To apply the action to all sessions, use the version without the ex suffix. To apply the action to a specific session, use the version with the session identifier with the ex suffix. For example, mldap_logon logs on to the LDAP server globally, while mldap_logon_ex logs on to the LDAP server for a specific session.
In the following example, the user logs on to an LDAP server, ldap1. It adds an entry and then renames the OU attribute from Sales to Marketing.
Action() {// Logon to the LDAP server
mldap_logon("Login",
"URL=ldap://johnsmith:tiger@ldap1:80",LAST);
// Add an entry for Sally R. Jones
mldap_add("LDAP Add",
"DN=cn=Sally R. Jones,OU=Sales, DC=com",
"Name=givenName", "Value=Sally", ENDITEM,
"Name=initials", "Value=R", ENDITEM,
"Name=sn", "Value=Jones", ENDITEM,
"Name=objectClass", "Value=contact", ENDITEM,
LAST);
// Rename Sally's OU to Marketing
mldap_rename("LDAP Rename",
"DN=CN=Sally R. Jones,OU=Sales,DC=com",
"NewDN=OU=Marketing",
LAST);
// Logout from the LDAP server
mldap_logoff();
return 0; }
