Getting The User ID From Connections

IBM Connections has an evil setting that disables emails from being seen on the system, this is meant as a security setting, but it not only hides the email from the front end but from all the atom feeds, suddenly you don’t have a unique key to reference users on functions.

Well that’s not exactly true, you have a internal ID that IBM functions will accept instead e.g “A7B2C512-27E5-596C-8625-7AD4000843Z3”, the only problem is how in the heck do you GET HOLD OF IT?

If you are within a community you can get it from member lists and such but how about when you want to just want to get a name that is on the system, say to add it to a community, the only way I have found is to search for it and no you cant search for it by email as that is disabled.

You have to search for it by name which while not exactly precise does the job but even that is not an ultra easy function, here is a little function to do it for you.

    private String getUserID( String adminUserName, String adminPassword, String baseURL, String ProfileSearchURL, String SearchUser) throws NotesException {
        String Unid = "";
        try {
            // example values for the passed parameters.
            adminUserName = "administrator"; 
            adminPassword = "password"; 
            baseURL = ""; 
            ProfileSearchURL = "/profiles/atom/"; //sthis is what connections 4 uses 
            SearchUser = "John Smith";
            //build our search string
            String searchString = baseURL + ProfileSearchURL + URLEncoder.encode(SearchUser, "UTF-8");
            Abdera abdera = new Abdera();
            AbderaClient client = new AbderaClient(abdera);
            //ensure we can handle SSL requests
            //logon to connections
            client.addCredentials(baseURL, null, null, new UsernamePasswordCredentials(adminUserName,adminPassword));
            //make the call
            ClientResponse resp = client.get(searchString );
            XPath xpath = abdera.getXPath();
            //get the xml back an navigate to the root of the document
            org.apache.abdera.model.Document doc = resp.getDocument();
            Feed feed = (Feed) doc.getRoot();          
            //if there is more than 1 returned entry then the user name is none unique and we cant trust our response
            if (xpath.numericValueOf("count(/a:feed/a:entry)", feed).intValue() > 1) {
                System.out.println("Ack we have more than 1 user with that name I cant be certain I have got the right one");
            } else {
                //as there is only one entry we can navigate straight down to the contributer sectnio which contains the user id
                Object contrubuternode = xpath.selectSingleNode("/a:feed/a:entry/a:contributor", feed );
                //because of the "snx" part we cant get the value without passing xpath our namespaces from the feed so it knows what "snx" means
                String snxUserid = xpath.valueOf("snx:userid", (Base) contrubuternode, feed.getNamespaces());
                Unid = snxUserid;   
        } catch (ClassCastException e) {
            System.out.println("no user found or some other garbage return");
            Unid = ""; 
        } catch (Exception e) {
        return Unid;

Leave a Reply

Your email address will not be published.