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.


// Logon to the LDAP server



// 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,


// Rename Sally's OU to Marketing

mldap_rename("LDAP Rename",

         "DN=CN=Sally R. Jones,OU=Sales,DC=com",



// Logout from the LDAP server


    return 0; }
Back to top