Skip to main content link. Accesskey S
  • Anonymous
  • Log on
  • Help
  • IBM logo
  • IBM Connections wiki
  • All Wikis
  • Home
  • Community Articles
  • Product Documentation
  • Learning Center


Search

Advanced Search

Categories

Tag Cloud

  • 1.0
  • 1.0.x
  • 2.0
  • 2.0.1
  • 2.0.1.1
  • 2.0_media
  • 2.5
  • 2.5_deployment
  • 2.5_media
  • 2.5_performance
  • 3
  • 3.0
  • 3.0.1
  • 3.0.1_media
  • 3.0_media
  • 3_deployment
  • 8.1.1
  • 8.2
  • activities
  • administrators
  • api
  • best_practices
  • blogs
  • bookmarks
  • business_card
  • cluster
  • communities
  • community
  • community_manager
  • connections
  • connections_3
  • connections_301
  • customization
  • customize
  • customizing
  • demos
  • deploying
  • deployment
  • deployments
  • developers
  • dogear
  • Domino
  • Edge server
  • education
  • error messages
  • files
  • forums
  • getting_started
  • Help
  • home
  • home_page
  • homepage
  • how-to
  • HTTP server
  • ibm
  • index
  • installation
  • integration
  • iOS
  • ipad
  • iWidget
  • J2EE
  • javadoc
  • lc3.0
  • learning
  • lotus-connections
  • mml
  • mobile
  • Notes
  • performance
  • person_card
  • Portal
  • portlet
  • portlet_factory
  • profiles
  • proxy server
  • quickr
  • Redbooks
  • rest
  • reverse proxy server
  • Sametime
  • scenarios
  • search
  • security
  • self-paced
  • SSO
  • tags
  • test_infrastructure
  • troubleshooting
  • tuning
  • video
  • VideoFest
  • videos
  • WAI
  • WAS
  • web_seminar
  • WebAppIntegrator
  • WebSphere
  • widgets
  • wikis
InformationInformation
You are currently viewing machine translated content. IBM translation might be available. Click IBM Translated Product Documentation to see what is available.X


Home > IBM Redbooks: Customizing IBM Connections 3.0.1 > 9.7 Using Profiles Administration APIs
Rate this article 1 starRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

9.7 Using Profiles Administration APIs 

expanded Abstract
collapsed Abstract
No abstract provided.
Previous

The Profiles Administration API was designed as an alternative to Tivoli Directory Integrator (TDI) for managing users in the IBM Connections database repository. The Profiles Administration API serves a different purpose than the regular Profiles API. The regular Profiles API is designed to work with only the authenticated user. The Profiles Administration API can be used to create, update, or delete users similar to the functions of TDI. For some environments, the Profiles Administration API could replace Tivoli Directory Integrator, but typically, the two will work in conjunction.
 
Much like the other APIs, the Profiles Administration API uses a REST-style interface. As such, the Abdera library provides most of the functionality to work with this API.
 
Before using the Profiles Administration API, a user has to be mapped to the "admin" role in the Profiles application. Only users with the admin role can use the Profiles Administration API. To add a user to the admin role in the Profiles application, open the WebSphere Application Server Administrative Console. Navigate to the security role mapping form for the Profiles application by selecting Applications -> Application Types -> WebSphere enterprise applications -> Profiles, and then Security role to user or group mapping as shown in the following screen:
 
Profiles Admin Role
 
The following sample code retrieves an existing user using an email address parameter:
 
Abdera abdera = new Abdera();
 
AbderaClient client = new AbderaClient(abdera);
AbderaClient.registerTrustManager();
    
client.addCredentials("http://servername", null, null, new UsernamePasswordCredentials("user","password"));
ClientResponse resp = client.get("http://servername/profiles/admin/atom/profileService.do");
 
Document<Service> service_doc = resp.getDocument();
Service service = service_doc.getRoot();
Collection collection = service.getCollection("Profiles Administration Workspace", "All User Profiles");
 
String coll_uri = collection.getResolvedHref().toASCIIString() + "?email=" + emailAddress;
 
resp = client.get(coll_uri);
 
switch(resp.getType()) {
        case SUCCESS:
                Document<Element> doc = resp.getDocument();
                doc.writeTo(System.out);
        break;
 
        default:
                System.out.println("Error: " + resp.getStatusText());
} 

 
The following code creates a user from a profile document:
 
Abdera abdera = new Abdera();
 
AbderaClient client = new AbderaClient(abdera);
AbderaClient.registerTrustManager();
    
client.addCredentials("http://servername", null, null, new UsernamePasswordCredentials("user","password"));
   
ClientResponse resp = client.get("http://servername/profiles/admin/atom/profileService.do");
 
Document<Service> service_doc = resp.getDocument();
Service service = service_doc.getRoot();
Collection collection = service.getCollection("Profiles Administration Workspace", "All User Profiles");
  
String coll_uri = collection.getResolvedHref().toASCIIString() + "?email=user@domain.com";
 
Entry entry = abdera.newEntry();
        
entry.setId("ignored");
        
entry.addCategory("http://www.ibm.com/xmlns/prod/sn/type", "profile", null);

try {
 
         File f = new File("NewProfile.xml");
         FileReader fr = new FileReader(f);
         BufferedReader br = new BufferedReader(fr);

        StringBuffer sb = new StringBuffer();
        String eachLine = br.readLine();
 
        while (eachLine != null) {
                sb.append(eachLine);
                sb.append("\n");
                eachLine = br.readLine();
        }
   
        entry.setContent(sb.toString(),Type.XML);
   
        } catch (Exception e) {
            e.printStackTrace();
 
        }
  
        resp = client.post(coll_uri, entry);
  
        switch(resp.getType()) {
        case SUCCESS:
                System.out.println("New profile created.");
                break;
        default:
                System.out.println("Error: " + resp.getStatusText());
} 

 
The Profiles Administration API can also be used to update a user. Note that when updating a user, all attributes should be passed to the API. So, first retrieve the user's profile document. Then after making updates to the profile document, post the new document using the same procedure used to add the user. The following is a sample profile document:
 
<person xmlns="http://ns.opensocial.org/2008/opensocial">
    <com.ibm.snx_profiles.attrib>
        <entry>
            <key>com.ibm.snx_profiles.base.distinguishedName</key>
            <value>
                <type>text</type>
                <data>CN=Frank Adams,o=Renovations</data>
            </value>
        </entry>
        <entry>
            <key>com.ibm.snx_profiles.base.guid</key>
            <value>
                <type>text</type>
                <data>E514AA26290C91108525688600530CA2</data>
            </value>
        </entry>
        <entry>
            <key>com.ibm.snx_profiles.base.uid</key>
            <value>
                <type>text</type>
                <data>fadams</data>
            </value>
        </entry>
        <entry>
            <key>com.ibm.snx_profiles.base.givenName</key>
            <value>
                <type>text</type>
                <data>Frank</data>
            </value>
        </entry>
        <entry>
            <key>com.ibm.snx_profiles.base.surname</key>
            <value>
                <type>text</type>
                <data>Adams</data>
            </value>
        </entry>
        <entry>
            <key>com.ibm.snx_profiles.base.email</key> 
            <value>
                <type>text</type> 
                <data>frank.adams@ibmdemo.com</data> 
            </value>
        </entry>
        <entry>
            <key>com.ibm.snx_profiles.base.displayName</key> 
            <value>
                <type>text</type> 
                <data>Frank Adams</data>
            </value>
        </entry>
    </com.ibm.snx_profiles.attrib>
</person>

 
It is important to note that extension attributes are available through the Profiles Administration API. Extension attributes can be retrieved and updated using the Profiles Administration API.

Parent topic: 9.0 Using the API

expanded Article information
collapsed Article information
Category:
IBM Redbooks: Customizing IBM Connections 3.0.1
Tags:
Redbooks

This Version: Version 2 November 22, 2011 12:05:13 PM by Amanda J Bauman  IBMer

expanded Attachments (0)
collapsed Attachments (0)

 


expanded Versions (2)
collapsed Versions (2)
Version Comparison     
Version Date Changed by               Summary of changes
This version (2) Nov 22, 2011 12:05:13 PM Amanda J Bauman  
1 Nov 21, 2011 1:15:16 PM Amanda J Bauman  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedSubscribe to RSSHelpAbout
  • All Lotus and WebSphere Portal wikis
  • IBM developerWorks
  • IBM Software support
  • IBM Social Business User Experience Blog
  • IBMSocialBizUX on Twitter
  • IBMSocialBizUX on Facebook
  • Lotus product forums
  • IBM Social Business UX blog
  • IBM Collaboration Solutions
  • Recently added feedRecently added
  • Recently edited feedRecently edited
  • Recently added comments feedRecently Added Comments
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Contact IBM
  • IBM Terms of use
  • Wiki terms of use