Monday, 21 December 2015

Creating a new Object Store in FileNet 5.1

//Creating a new Object Store in FileNet 5.1

3 main steps required for creating a new object store
  1. Create a new Data Base
  2. Create XA and Non-XA Data Sources in WebSphere
  3. Create a new Object Store using FileNet Enterprise Manager Administration Tool 
1. Create a new Data Base (Here i am creating a database in SQL Server)






2. Create XA and Non-XA Data Sources in WebSphere

(Non-XA Data Source)
2.1 Log-on to WebSphere console and navigate to Data Sources as shown below and Click on New

  


2.2 Enter Data source name and JNDI name and click on Next

2.3 Select Non-XA data source as shown below and click on NEXT 


2.4 Enter Database Name, Port number, Server Name and Click on Next

2.5 Select "Component-managed Authentication alias" (for Authentication) and click on Next and Finish it.
2.6 Test the connection.

(XA Data Source)

 2.7 Log-on to WebSphere console and navigate to Data Sources as shown below and Click on New
 
 
2.8 Enter Data source name and JNDI name and click on Next

2.9 Select XA data source as shown below and click on NEXT

2.10 Select "Component-managed Authentication alias" (for Authentication) and click on Next and Finish it.
   
2.11 Test the two (XA and Non XA Data Sources).


3. Create a new Object Store using FileNet Enterprise Manager Administration Tool  

3.1 Log on to FileNet Enterprise Manager Administration Tool (FEM)

3.2 Right click on Object Stores and click on New Object Store

3.3 Click on Next

3.4 Enter Display Name*, Symbolic Name* and Description and click on Next

 3.5 Enter JNDI Data Source Name, JNDI XA Data Source Name (Same as you created in 2 Step) and Click on Next

3.5  Create a new empty folder in Windows (or Linux)(For File Storage Area) (Here Folder Name : RAKESHOS)

 
3.6 Select File Storage Area and click on Next.

3.7 Browse... the Root Directory of Folder  (Here I am selecting RAKESHOS folder) and Click on Next



 3.8 Enter Storage Area Details as shown below and Click on Next

3.9 Add user(s) or (and) groups that should have administrative access to the object store and Click on Next

 3.10 Add user(s) or (and) groups that should have basic, non-administrative access to the object store

3.11 Select AddOns to install(Minimal AddOns mandatory) and Click on Next. Select the AddOns based on your requirement (for example Case Manager Target object store or Design object store or (and) Workplace/XT AddOns)  (Hare i am selecting Workplace/XT and Case Manager Target Object store related AddOns) .



3.12 Finish the changes and it will take some time to create a Object Store.




 ....Object Store created successfully...

****************************************************************************************

Friday, 11 December 2015

Java code to Create/Delete user in LDAP

//Java code to Create/Delete user in LDAP

// Establish a LDAP connection

public static LdapContext getInitialLdapContext()
        throws Exception
    {
        LdapContext ctx = null;
        String dnusername = "cn=root,ou=users, o=sample,c=country"; //Admin user name
        String dnpwd = "abcd@123"; //Admin Password
        try
        {
            Control rctls[] = {new PasswordPolicyControl(true)};
            String ldapHostName = bundle.getString("LDAP_IP");
            String ldapHostRMIPort = bundle.getString("LDAP_PORT");
            String providerURL = (new StringBuilder("ldap://")).append(ldapHostName).append(":").append(ldapHostRMIPort).toString();
            System.out.println("URL  =  "+ providerURL);
            Hashtable env = new Hashtable();
            env.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");
            env.put("java.naming.provider.url", providerURL);
            env.put("java.naming.security.authentication", "simple");
            env.put("java.naming.security.principal", dnusername);
            env.put("java.naming.security.credentials", dnpwd);
            ctx = new InitialLdapContext(env, rctls);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        return ctx;
    }
    private static String getUserDN(String username)
    {
        return (new StringBuilder("cn=")).append(username).append(",").append("ou=users, o=sample,c=country").toString();
    }
   
   
    //Create a user
   private static void addUser(String username, String surname,  String titleprop, String mailprop, String employeenumberprop, String mobileprop, String displayNameprop, String password)
       // throws NamingException
    {
        private static DirContext context;
        context = getInitialLdapContext();
        Attributes container = new BasicAttributes();
        Attribute objClasses = new BasicAttribute("objectClass");
        objClasses.add("organizationalPerson");
        objClasses.add("inetOrgPerson");
        objClasses.add("person");
        objClasses.add("top");
        Attribute cn = new BasicAttribute("cn", username);
        Attribute sn = new BasicAttribute("sn", surname);
        Attribute uid = new BasicAttribute("uid", username);
        Attribute title = new BasicAttribute("title", titleprop);
        Attribute mail = new BasicAttribute("mail", mailprop);
        Attribute mobile = new BasicAttribute("mobile", mobileprop);
        Attribute employeeNumber = new BasicAttribute("employeeNumber", employeenumberprop);
        Attribute userPassword = new BasicAttribute("userpassword", password);
        Attribute  displayName = new BasicAttribute("displayName",displayNameprop);
        container.put(objClasses);
        container.put(sn);
        container.put(uid);
        container.put(title);
        container.put(mail);
        container.put(mobile);
        container.put(employeeNumber);
        container.put(countryCode);
        container.put(displayName);

        container.put(userPassword);
       try{
        context.createSubcontext(getUserDN(username), container);
       }
       catch (Exception e) {
        // TODO: handle exception
           log.info(e);
    }
       
       System.out.println((new StringBuilder(String.valueOf(password))).append("- is the Password for user- ").append(username).toString());
       
    }
   
    //Delete a user
    private static void deleteUser(String username)
        throws NamingException
    {
        try
        {
            context.destroySubcontext(getUserDN(username));
            System.out.println((new StringBuilder("User has been deleted successfully - ")).append(username).toString());
        }
        catch(NameNotFoundException namenotfoundexception) {
            log.info(namenotfoundexception);
        }
    }