Documentum DFC to check if users exist in the docbase

Damien_Elliott
edited February 8, 2018 in TeamSite #1

Currently as part of a tool that has been designed to add users to a role we have been using the following code to add them. However, if it encounters a user that does not exist in the docbase it will stop running there, is there any way to check if the users exist before trying to add them and to then skip over the user that does not exist?

    private static void loadUsers(String userfile,IDfGroup group){
        System.out.println("Connecting.. and loading file," + userfile);
            String userName = null;

            try {
                FileReader fileReader = new FileReader(userfile);

                BufferedReader bufferedReader = new BufferedReader(fileReader);
                while((userName = bufferedReader.readLine()) != null) {
                                            System.out.println(userName);
                        group.addUser(userName);
                            group.save();
                }   

                bufferedReader.close();         
                }

Answers

  • Akshay_Sonawane
    edited February 9, 2018 #2

    Simply Query on dm_user and if you get result then the user exists in doc base else he is not

    String dql = "SELECT * from dm_user where user_name =''";
    IDfQuery query = new DfQuery();
    query.setDQL(dql);
    collection = null;
    String docName = null;
    count = 0;
    try {
    collection = query.execute(session, IDfQuery.DF_READ_QUERY);
    while (collection.next()) {
    count++;
    break;
    }

    if(count>0)
    {
    //Add USER
    }
    else
    {
    //SKIP User
    }

    } finally {

    if (collection != null) {
    collection.close();
    }
    }

    Regards,
    Akshay

TeamSite Developer Resources

  • Docker Automation

  • LiveSite Content Services (LSCS) REST API

  • Single Page Application (SPA) Modules

  • TeamSite Add-ons

If you are interested in gaining full access to the content, you can register for a My Support account here.
image
OpenText CE Products
TeamSite
APIs