Skip to Content
avatar image
Former Member

How to get the list of deactivate users in the BO platform.

Hi All,

Recently we did a migration, I need get list of all deactivate users in the platform. Anybody have idea how to get all the users list.

thanks.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • May 11, 2017 at 03:18 PM

    Hi Everyone,

    I have created a small Java Automation Program using BO Java SDK to Intimate/Disable/Enable BO Users. The objectives of this program are:

    1. Identify the list of BO Users who have not logged in to Business Objects for the last 80 days.
    2. Save their Email ID in a CSV file at a shared location and send a email to each of these users intimating that their account will be deactivated after 10 days if they do not log in at least once in the next 10 days.
    3. Run this program again and this time identify the list of BO Users who have not logged in to Business Objects for the last 90 days.
    4. Disable the user account by disabling all the aliases of these users (Note: We are not Deleting the BO User Account)
    5. If you disable the BO users and then you are asked to revert this action and bring all accounts alive then run this program again and enable them all.
    6. Same program should run for BOXI R3 and BOXI R4 (for this include cesdk.jar and mail.jar from from BO 3.1 Jar library so that it runs for both versions otherwise use the JAR from BOXI 4.1 library)
    7. Create a runnable JAR file so that you can run it either from command line or schedule it through Windows Scheduler
    8. Compile the program using SAPJVM (provided in the BO Installation directory)

    Please note that you should use your company's BO Server/SMTP details/Email ID etc.

    To run this program through Command Line for BOXI R3
    cd C:\Program Files\Business Objects\sapjvm\bin
    java -jar "Z:\Workspace\Disable User\BOR3\DisableUser.jar" r3 BOUserName BOPassword BOServer:6400 secEnterprise intimate/disable/enable

    To run this program through Command Line for BOXI R4
    cd C:\Program Files\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x86\sapjvm\bin
    java -jar "Z:\Workspace\Disable User\BOR4\DisableUser\DisableUser.jar" r4 BOUserName BOPassword BOServer:6400 secEnterprise intimate/disable/enable

    I hope this program helps. Please comment if you have any question.

    Kind Regards,
    Manish

    **************************************
    JAVA PROGRAM
    **************************************

    package DUPackage;

    import java.io.FileWriter;
    import java.util.Properties;
    import java.util.Calendar;
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.AddressException;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    import com.crystaldecisions.sdk.framework.CrystalEnterprise;
    import com.crystaldecisions.sdk.framework.IEnterpriseSession;
    import com.crystaldecisions.sdk.framework.ISessionMgr;
    import com.crystaldecisions.sdk.occa.infostore.IInfoObject;
    import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;
    import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
    import com.crystaldecisions.sdk.plugin.desktop.user.IUser;
    import com.crystaldecisions.sdk.plugin.desktop.user.IUserAlias;
    import com.crystaldecisions.sdk.plugin.desktop.user.IUserAliases;

    public class DUClass {
    public static void main(String[] args) {
    String csvFile = null;
    String mailSubject = null;
    String mailText = null;
    String sFromDate = null;
    String sTodayDateTime = null;
    String sQuery = null;
    String sProdBOUrl = null;
    String sEmailFlag = "No";
    String sVersion = args[0];
    String sUserName = args[1];
    String sPassword = args[2];
    String sServer = args[3];
    String sAuthentication = args[4];
    String sChoice = args[5];

    if (sVersion.equals("r3")) {
    sVersion = "3.1";
    sProdBOUrl = "
    https://BOSERVER/InfoViewApp/logon.jsp";
    }

    if (sVersion.equals("r4")) {
    sVersion = "4.1";
    sProdBOUrl = "
    https://BOSERVER/BOE/BI";
    }

    Calendar cal = Calendar.getInstance();

    if (sChoice.equals("intimate")) {
    sTodayDateTime = getTodayDate(cal);
    csvFile = "//BI_User_Mgmt/remove_access/BO_Intimate_User_List - "
    + sTodayDateTime + ".csv";
    cal.add(Calendar.DATE, -80);
    sFromDate = getDate(cal);
    sQuery = "SELECT * FROM ci_systemobjects WHERE si_kind='User' AND SI_NAME NOT IN ('PMUser', 'Guest') AND "
    + "NOT (DESCENDANTS(\"SI_NAME='USERGROUP-USER'\", \"SI_NAME='ADMINISTRATORS'\") OR DESCENDANTS(\"SI_NAME='USERGROUP-USER'\", \"SI_NAME='Protected Licenses'\")) AND "
    + "(si_lastlogontime <= '"
    + sFromDate
    + "' OR (si_lastlogontime = NULL and SI_CREATION_TIME <= '"
    + sFromDate
    + "'))"
    + "ORDER BY si_lastlogontime, SI_CREATION_TIME";

    mailSubject = "NOTIFICATION - Inactive Business Objects "
    + sVersion + " Production Users longer than 80 Days";
    mailText = "Dear BO User \n\n"
    + "Your Business Objects "
    + sVersion
    + " Production Inactivity has been identified to be more than 80 Days. \n\n"
    + "Your Business Objects Access may be disabled automatically when the execution time exceeds 90 days.\n\n"
    + "Kindly login to Business Objects in the next 10 days of this email to keep your BO account active.\n\n"
    + "\tApplication URL: " + sProdBOUrl + "\n"
    + "\tUser Name: Your LAN ID\n"
    + "\tPassword: Your LAN Password\n\n\n" + "Regards, \n"
    + "Business Objects Admin Team";
    } else if (sChoice.equals("disable")) {
    sTodayDateTime = getTodayDate(cal);
    csvFile = "//BI_User_Mgmt/remove_access/BO_Disable_User_List - "
    + sTodayDateTime + ".csv";
    cal.add(Calendar.DATE, -90);
    sFromDate = getDate(cal);
    sQuery = "SELECT * FROM ci_systemobjects WHERE si_kind='User' AND SI_NAME NOT IN ('PMUser', 'Guest') AND "
    + "NOT (DESCENDANTS(\"SI_NAME='USERGROUP-USER'\", \"SI_NAME='ADMINISTRATORS'\") OR DESCENDANTS(\"SI_NAME='USERGROUP-USER'\", \"SI_NAME='Protected Licenses'\")) AND "
    + "(si_lastlogontime <= '"
    + sFromDate
    + "' OR (si_lastlogontime = NULL and SI_CREATION_TIME <= '"
    + sFromDate
    + "'))"
    + "ORDER BY si_lastlogontime, SI_CREATION_TIME";

    mailSubject = "NOTIFICATION - Inactive Business Objects "
    + sVersion + " Production Users longer than 90 Days";
    mailText = "Dear BO User \n\n"
    + "Your Business Objects "
    + sVersion
    + " Production Access has been disabled.\n\n"
    + "Your Business Objects Inactivity has been identified to be more than 90 Days. \n\n"
    + "If you would like to use Business Objects again for reporting purpose, kindly raise a ticket in Service Market Place.\n\n\n"
    + "Regards, \n" + "Business Objects Admin Team";
    } else if (sChoice.equals("enable")) {
    sTodayDateTime = getTodayDate(cal);
    csvFile = "//BI_User_Mgmt/remove_access/BO_Enable_User_List - "
    + sTodayDateTime + ".csv";
    cal.add(Calendar.DATE, -90);
    sFromDate = getDate(cal);
    sQuery = "SELECT * FROM ci_systemobjects WHERE si_kind='User' AND SI_NAME NOT IN ('PMUser', 'Guest') AND "
    + "NOT (DESCENDANTS(\"SI_NAME='USERGROUP-USER'\", \"SI_NAME='ADMINISTRATORS'\") OR DESCENDANTS(\"SI_NAME='USERGROUP-USER'\", \"SI_NAME='Protected Licenses'\")) AND "
    + "(si_lastlogontime <= '"
    + sFromDate
    + "' OR (si_lastlogontime = NULL and SI_CREATION_TIME <= '"
    + sFromDate
    + "'))"
    + "ORDER BY si_lastlogontime, SI_CREATION_TIME";

    mailSubject = "NOTIFICATION - Business Objects " + sVersion
    + " Production - Account Unlocked";
    mailText = "Dear BO User \n\n"
    + "Your Business Objects "
    + sVersion
    + " Production account has been unlocked. \n\n"
    + "Kindly login to Business Objects using the following details.\n\n"
    + "\tApplication URL: " + sProdBOUrl + "\n"
    + "\tUser Name: Your LAN ID\n"
    + "\tPassword: Your LAN Password\n\n\n" + "Regards, \n"
    + "Business Objects Admin Team";
    } else {
    System.out.println("\nIncorrect parameter passed. Please re-try!!");
    System.exit(0);
    }

    IEnterpriseSession enterpriseSession = null;
    try {
    System.out.println("\nConnecting to BO " + sVersion + " Server");
    ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr();
    enterpriseSession = sessionMgr.logon(sUserName, sPassword, sServer,
    sAuthentication);
    IInfoStore infoStore = (IInfoStore) enterpriseSession
    .getService("InfoStore");
    System.out.println("\nConnection Successful\n");
    System.out.println("Query Used:\n");
    System.out.println(sQuery + "\n\n");
    FileWriter writer = new FileWriter(csvFile);
    IInfoObjects infoObjects = (IInfoObjects) infoStore.query(sQuery);

    if (sChoice.equals("intimate")) {
    for (Object object : infoObjects) {
    IInfoObject existingUser = (IInfoObject) object;
    if (existingUser instanceof IUser) {
    IUser iUser = (IUser) existingUser;
    IUserAliases existingAliases = iUser.getAliases();
    for (java.util.Iterator<IUserAlias> it = existingAliases
    .iterator(); it.hasNext();) {
    IUserAlias sAlias = (IUserAlias) it.next();
    if ((sAlias.isDisabled() == false)
    && iUser.getEmailAddress().contains("@")) {
    sEmailFlag = "Yes";
    }
    }
    if (sEmailFlag.equals("Yes")) {
    writer.append(iUser.getEmailAddress() + '\n');
    sendEmail(iUser.getEmailAddress(), mailSubject,
    mailText);
    sEmailFlag = "No";
    }
    }
    }
    }
    if (sChoice.equals("disable")) {
    for (Object object : infoObjects) {
    IInfoObject existingUser = (IInfoObject) object;
    if (existingUser instanceof IUser) {
    IUser iUser = (IUser) existingUser;
    IUserAliases existingAliases = iUser.getAliases();
    for (java.util.Iterator<IUserAlias> it = existingAliases
    .iterator(); it.hasNext();) {
    IUserAlias sAlias = (IUserAlias) it.next();
    if ((sAlias.isDisabled() == false)) {
    sAlias.setDisabled(true);
    infoStore.commit(infoObjects);
    sEmailFlag = "Yes";
    }
    }
    if (sEmailFlag.equals("Yes")
    && iUser.getEmailAddress().contains("@")) {
    writer.append(iUser.getEmailAddress() + '\n');
    sendEmail(iUser.getEmailAddress(), mailSubject,
    mailText);
    }
    sEmailFlag = "No";
    }
    }
    }
    if (sChoice.equals("enable")) {
    for (Object object : infoObjects) {
    IInfoObject existingUser = (IInfoObject) object;
    if (existingUser instanceof IUser) {
    IUser iUser = (IUser) existingUser;
    IUserAliases existingAliases = iUser.getAliases();
    for (java.util.Iterator<IUserAlias> it = existingAliases
    .iterator(); it.hasNext();) {
    IUserAlias sAlias = (IUserAlias) it.next();
    if ((sAlias.isDisabled() == true)) {
    sAlias.setDisabled(false);
    infoStore.commit(infoObjects);
    sEmailFlag = "Yes";
    }
    }
    if (sEmailFlag.equals("Yes")
    && iUser.getEmailAddress().contains("@")) {
    writer.append(iUser.getEmailAddress() + '\n');
    sendEmail(iUser.getEmailAddress(), mailSubject,
    mailText);
    }
    sEmailFlag = "No";
    }
    }
    }

    writer.flush();
    writer.close();
    } catch (Exception ex) {
    System.out.println("Exception" + ex);
    ex.printStackTrace();
    } finally {
    if (enterpriseSession != null) {
    enterpriseSession.logoff();
    System.out.println("\nFinished!");
    }
    }
    }

    public static String getDate(Calendar cal) {
    return "" + cal.get(Calendar.YEAR) + "."
    + (cal.get(Calendar.MONTH) + 1) + "." + cal.get(Calendar.DATE)
    + ".23.59.59";
    }

    public static String getTodayDate(Calendar cal) {
    return "" + cal.get(Calendar.YEAR) + "."
    + (cal.get(Calendar.MONTH) + 1) + "." + cal.get(Calendar.DATE)
    + "." + cal.get(Calendar.HOUR_OF_DAY) + "."
    + (cal.get(Calendar.MINUTE)) + "." + cal.get(Calendar.SECOND);
    }

    public static void sendEmail(String mailTo, String mailSubject,
    String mailText) {
    try {
    String mailSmtpHost = "xyz.com";

    String mailFrom = "abc@xyz.com";

    Properties properties = new Properties();
    properties.put("mail.smtp.host", mailSmtpHost);
    Session emailSession = Session.getDefaultInstance(properties);

    Message emailMessage = new MimeMessage(emailSession);
    emailMessage.addRecipient(Message.RecipientType.TO,
    new InternetAddress(mailTo));

    emailMessage.setFrom(new InternetAddress(mailFrom));
    emailMessage.setSubject(mailSubject);
    emailMessage.setText(mailText);
    Transport.send(emailMessage);
    } catch (AddressException e) {
    e.printStackTrace();
    } catch (MessagingException e) {
    e.printStackTrace();
    }
    }
    }

    Add comment
    10|10000 characters needed characters exceeded