Showing posts with label Active Directory. Show all posts
Showing posts with label Active Directory. Show all posts

Tuesday, February 23, 2021

Working with Documents : Create a Document in FileNet using Java CE API

 

    Creating a Document

This code creates a document in object store with Document class and file in a folder using                     Referential Containment Relationship

// Write the connection code here or click here to get the connection code 

Domain domain = Factory.Domain.fetchInstance(connection, null, null);

ObjectStore os = Factory.ObjectStore.fetchInstance(domain, "your object store name", null);

Document doc = Factory.Document.createInstance(os, ClassNames.DOCUMENT);

                doc.getProperties().putValue("DocumentTitle", "Your Document Title");

                doc.set_MimeType("text/plain");

                StorageArea sa = Factory.StorageArea.getInstance(os, new Id("{********-****-****-****-************}"));

                doc.set_StorageArea(sa);

                doc.save(RefreshMode.NO_REFRESH);

                doc.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY,

                CheckinType.MAJOR_VERSION);

                doc.save(RefreshMode.NO_REFRESH);

get the folder object where you want to place the  newly created document

                Folder folder = Factory.Folder.getInstance(os, ClassNames.FOLDER,new Id("{********-****-****-****-************}") );

                The below code will place the document in the folder 

ReferentialContainmentRelationship rcr = folder.file(doc,

                 AutoUniqueName.AUTO_UNIQUE, "Adding New Document with Java Code",

                 DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE);

                rcr.save(RefreshMode.NO_REFRESH);

               

Wednesday, January 27, 2021

FileNet and Ldap connectivity - java code to get Active Directory Connection

 

//Connecting to LDAP using java code

String rootDN = "CN=xyz,CN=xyz,DC=xyz,DC=xyz";

        String rootPWD = "*****";

        Hashtable<String, String> environment = new Hashtable<String, String>();

        environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");

        environment.put(Context.PROVIDER_URL, "<ldapurl>");

        environment.put(Context.SECURITY_AUTHENTICATION, "authentications type");

        environment.put(Context.SECURITY_PRINCIPAL, rootDN);

        environment.put(Context.SECURITY_CREDENTIALS, rootPWD);

        DirContext dirContext = null;

        NamingEnumeration<?> results = null;

dirContext = new InitialDirContext(environment);

FileNet - Fetch the users and all attributes from Active Directory and AD Connection and setting all environment variables for AD


Connecting to Active Directory



ArrayList getListValues(){

// Connect to the Active Directory here or click here for Connection code

ArrayList list = new ArrayList();

        SearchControls searchctrl = new SearchControls();

        searchctrl.setSearchScope(SearchControls.SUBTREE_SCOPE);

        searchctrl.setReturningAttributes(new String[]{"name or id"}); \\ attributes which we are retriving from AD

        results = dirContext.search("", "(objectclass=user)", searchctrl);

        while(results.hasMore()){

        SearchResult res = (SearchResult) results.next();

        Attributes attributes = res.getAttributes();

        Enumeration attribute = attributes.getAll();

        while(attribute.hasMoreElements()){

        Attribute attr = (Attribute) attribute.nextElement();

        if(!attr.toString().equals("") && !attr.toString().equals(null)){

        list.add(attr.toString());

        }

        }       

          }       

              return list;

}

IBM Case Manager script - Select User Dialog box on Filed Focus event - to select user from the list of LDAP Users (ecm.widget.dialog.SelectUserGroupDialog)

if(payload.eventName === "icm.FieldFocused"){

if(payload.id === "PRX_Name")

{

 callback = function(users){

                        this.propController.set("value", users[0].shortName);

                        }; 

                    var selectUserDialog = new ecm.widget.dialog.SelectUserGroupDialog({

                                            queryMode: "users",

                                            selectionMode :"single",

                                            callback: dojo.hitch(this,callback)

                                            });

                    selectUserDialog.show(solution.getTargetOS());    

}

}