Showing posts with label LDAP. Show all posts
Showing posts with label LDAP. Show all posts

Thursday, November 1, 2012

Retrieval of user details of logged-in Cordys user

Retrieval of the user details of the logged-in user can be easily done using the BSF and LDAP build-in utility functions.

Below an example of a Java function which retrieves the ‘Full User Name’ and ‘email’ adres which is shown within the Cordys User Manager. Furthermore, it retrieves the ‘Full Organization Name’ from the Cordys Organisation Manager.

/**
  * This method returns the raadpleger details of the logged-in user.
  *
  * @return  A string array with 3 values:
  *  - value 1: Full Name of the logged-in user
  *  - value 2: Email of the logged-in user
  *  - value 3: Full Name of the organization of the user
 */
 public static String[] getRaadplegerDetails()
 {
    String[] raadplegerDetails = new String[3];

String userDN = BSF.getUser();

    String orgDN = BSF.getOrganization();
   
LDAPDirectory ldir = LDAPDirectory.getDefaultInstance();
        LDAPEntry userLdapEntry = ldir.read(userDN);
        LDAPEntry orgLdapEntry = ldir.read(orgDN);

        // Check if it's an organizational user or an authenticated one.
        LDAPAttribute attr = userLdapEntry.getAttribute("objectclass");
        String[] classes = attr.getStringValueArray();
        boolean found = false;

        for (String className : classes)
        {
            if ("busorganizationaluser".equals(className))

            {
                found = true;
                break;
            }
}

        // Read the entry of the authenticated user if the passed on DN was of an org user.
if (found)
        {
            String authUser = LDAPUtils.getAttrValue(userLdapEntry, "authenticationuser");
            userLdapEntry = ldir.read(authUser);
}

        // Set the Full User Name
        raadplegerDetails[0] = LDAPUtils.getAttrValue(userLdapEntry, "description");
        // Set the Email
        raadplegerDetails[1] = LDAPUtils.getAttrValue(userLdapEntry, "mail");
        // Set the Full Organization Name
        raadplegerDetails[2] = LDAPUtils.getAttrValue(orgLdapEntry, "description");
    }
       return raadplegerDetails;
   }

Wednesday, January 26, 2011

Connect to CARS via external LDAP Client

Problem: How do we connect to Cordys Admin Repository Server (CARS) via an external LDAP client.

How:
Before starting to give a solution for this it is good to know that CARS by default uses one-way SSL for the CARS authentication. This can be changed  of course by adapting the default installation configuration of CARS, but this is not recommended.

Note: changes this can be done by adapting the property: ‘cars.sslmode ‘ withinin the file <instance-name>.properties, which is located within the Cordys install dir.

default CARS settings


Steps to be taken in order to connect to CARS via an external LDAP client

1. First check if you can connect using the Content Manager of the Cordys Management Console into CARS.



2. If step 1 succeeds (login successfull), take over the configuration of the connect screen of the Content Manager and use this information to connect via your external LDAP client (e.g. JXPlorer).



Using this way you are able to connect with your preferred LDAP client to the CARS OpenLDAP implemenation. Another nice LDAP client to use is Apache Directory Studio.

Have fun.