有效化/无效化所有的用户 |
---|
<%@ page import = "com.crystaldecisions.sdk.exception.SDKException, com.crystaldecisions.sdk.framework.*, com.crystaldecisions.sdk.occa.infostore.*, com.crystaldecisions.sdk.occa.report.*, com.crystaldecisions.sdk.properties.*, com.crystaldecisions.sdk.plugin.desktop.user.*, java.util.*" %> <% // 用户认证信息 // True - 无效化;False - 有效化 IEnterpriseSession enterpriseSession = null; // 登陆系统 // 用于查询的初始 SI_ID for(;;) { // 除去Administrator and Guest,循环所有用户 // 如果没有对象返回,处理结束. if(boInfoObjects.size() == 0) break; for(Iterator boCount = boInfoObjects.iterator() ; boCount.hasNext() ; ) { IInfoObject boObject = (IInfoObject)boCount.next(); IUser boUser = (IUser)boObject; Iterator boIterator = boUser.getAliases().iterator(); while(boIterator.hasNext()) { IUserAlias boAlias = (IUserAlias)boIterator.next(); out.println("current status is: " + boAlias.isDisabled()); boAlias.setDisabled(disableUsers); if (disableUsers) { out.println("user name: " + boAlias.getName() + " has been disabled<BR>"); } else { out.println("user name: " + boAlias.getName() + " has been enabled<BR>"); } } max_id = boObject.getID(); } infoStore.commit(boInfoObjects); } %> |
有效化/无效化某个用户组下的用户 |
---|
<%@ page import = "com.crystaldecisions.sdk.exception.SDKException, com.crystaldecisions.sdk.framework.*, com.crystaldecisions.sdk.occa.infostore.*, com.crystaldecisions.sdk.occa.report.*, com.crystaldecisions.sdk.properties.*, com.crystaldecisions.sdk.plugin.desktop.user.*, com.crystaldecisions.sdk.plugin.desktop.usergroup.*, java.util.*" %> <% // 用户认证信息 // True - 无效化;False - 有效化 IEnterpriseSession enterpriseSession = null; // 登陆系统 // 取得用户组 if(boInfoObjects.size() == 0) // 没有用户组返回,处理结束 out.println("No groups found with name " + groupName); } else { IUserGroup currentGroup = (IUserGroup)boInfoObjects.get(0); // 取得设定的游标对象 Set boUserList = currentGroup.getUsers(); IInfoObjects boInfoObjects2 = (IInfoObjects)infoStore.query("Select * FROM CI_SYSTEMOBJECTS WHERE SI_ID = " + boUserIterator.next()); IUser boUser = (IUser)boInfoObjects2.get(0); // Administrator or Guest 除外 if (boUser.getTitle().equals("Administrator") || boUser.getTitle().equals("Guest")) { Iterator boIterator = boUser.getAliases().iterator(); while(boIterator.hasNext()) { IUserAlias boAlias = (IUserAlias)boIterator.next(); boAlias.setDisabled(disableUsers); if (disableUsers) { out.println("user name: " + boAlias.getName() + " has been disabled<BR>"); } else { out.println("user name: " + boAlias.getName() + " has been enabled<BR>"); } } } infoStore.commit(boInfoObjects2); } } %> |
统计报表和实例的个数 |
---|
<%@ page import = "com.crystaldecisions.sdk.exception.SDKException, com.crystaldecisions.sdk.framework.*, com.crystaldecisions.sdk.occa.infostore.*, com.crystaldecisions.sdk.occa.report.*, com.crystaldecisions.sdk.properties.*, com.crystaldecisions.sdk.plugin.desktop.user.*, java.util.*, java.io.*" %> <% // 用户认证信息 IEnterpriseSession enterpriseSession = null; // 登陆系统 // 开始查询的起始 SI_ID writeToLog("UserID,UserName,ReportsOwned,ReportInstancesOwned"); for(;;) { // 循环所有用户 // 没有对象返回,处理结束. break; // 循环所有用户 IInfoObject boObject = (IInfoObject)boCount.next(); int max_id2 = 0; int max_id3 = 0; int countReports = 0; int countInstances = 0; // 循环所有报表模板,统计用户所有的报表数 for(;;) { IInfoObjects boInfoObjects2 = (IInfoObjects)infoStore.query("Select * FROM CI_INFOOBJECTS WHERE SI_OWNERID = " + boObject.getID() + " AND SI_INSTANCE=0 AND SI_ID > " + max_id2 + " AND (SI_KIND='CrystalReport' OR SI_KIND='Webi' OR SI_KIND = 'FullClient') ORDER BY SI_ID ASC"); // 没有对象返回,处理结束. if(boInfoObjects2.size() == 0) break; countReports+=countReports + boInfoObjects2.size(); max_id2 = ((IInfoObject)boInfoObjects2.get(boInfoObjects2.size()-1)).getID(); } // 循环所有报表实例,统计用户所有的报表数 IInfoObjects boInfoObjects3 = (IInfoObjects)infoStore.query("Select * FROM CI_INFOOBJECTS WHERE SI_OWNERID = " + boObject.getID() + " AND SI_INSTANCE=1 AND SI_ID > " + max_id3 + " ORDER BY SI_ID ASC"); // 没有对象返回,处理结束 if(boInfoObjects3.size() == 0) break; countInstances+=countInstances + boInfoObjects3.size(); max_id3 = ((IInfoObject)boInfoObjects3.get(boInfoObjects3.size()-1)).getID(); } writeToLog(boObject.getID() + "," + boObject.getTitle() + "," + countReports + "," + countInstances); max_id = boObject.getID(); } } %> <%! public void writeToLog(String msg) { try { // 设定日志文件 FileOutputStream FSout; PrintStream pStream; // 声明打印流对象 FSout = new FileOutputStream("C:\\TestOutput.csv", true); // 默认续写 pStream = new PrintStream(FSout); pStream.println(msg); pStream.close(); } catch (IOException e) { // 错误处理 } } %> |
改变报表所有者 |
---|
<%@ page import = "com.crystaldecisions.sdk.exception.SDKException, com.crystaldecisions.sdk.framework.*, com.crystaldecisions.sdk.occa.infostore.*, com.crystaldecisions.sdk.occa.report.*, com.crystaldecisions.sdk.properties.*, java.util.*" %> <% // 用户登录信息 String sourceUserID = "12345"; // SI_ID 源对象用户 (当前所有者) IEnterpriseSession enterpriseSession = null; // 登录系统 // 检索初始ID for(;;) { // 循环所有对象 // 没有对象返回,处理结束. break; for(Iterator boCount = boInfoObjects.iterator() ; boCount.hasNext() ; ) { IInfoObject boObject = (IInfoObject)boCount.next(); // 需要转换ID为interger,如果不转换,程序不会出错,但是也不会进行处理 out.println("Changed owner for report ID " + boObject.getID() + " with title " + boObject.getTitle() + "</br>"); max_id = boObject.getID(); } infoStore.commit(boInfoObjects); } %> |
复制用户的全局基本设定 |
---|
<%@ page import = "com.crystaldecisions.sdk.exception.SDKException, com.crystaldecisions.sdk.framework.*, com.crystaldecisions.sdk.occa.infostore.*, com.crystaldecisions.sdk.occa.report.*, com.crystaldecisions.sdk.properties.*, com.crystaldecisions.sdk.plugin.desktop.user.*, com.crystaldecisions.sdk.plugin.desktop.usergroup.*, java.util.*" %> <% // 登录信息 String sourceUserID = "12345"; IEnterpriseSession enterpriseSession = null; // 登陆系统 // 取得用户组 // 取得源用户 if(boInfoObjects.size() == 0 || boInfoObjects3.size() == 0) { // 找不到目标用户,用户组,则处理结束 if (boInfoObjects.size() == 0) { out.println("No groups found with name " + groupName); } else { out.println("No user found or use" + sourceUserID + " had null preferences section"); } } else { IUserGroup currentGroup = (IUserGroup)boInfoObjects.get(0); // 取得源用户的SI_DATA 集合 // 取得对象游标 Set boUserList = currentGroup.getUsers(); IInfoObjects boInfoObjects2 = (IInfoObjects)infoStore.query("Select * FROM CI_SYSTEMOBJECTS WHERE SI_ID = " + boUserIterator.next()); IUser boUser = (IUser)boInfoObjects2.get(0); // Administrator or Guest 用户除外 { IProperties targetProp = (IProperties)boUser.properties(); // 如果目标用户没有SI_DATA,添加并复制 // 如果存在,则覆写 if (targetProp.getProperty("SI_DATA") == null) { out.println("User " + boUser.getTitle() + " had no preferences set - assigning new preferences. </br>"); targetProp.add("SI_DATA", sourceProp,0); } else { out.println("User " + boUser.getTitle() + " had some preferences set - overwriting preferences. </br>"); targetProp.add("SI_DATA", sourceProp,0); } } infoStore.commit(boInfoObjects2); } } %> |
强制注销所有用户 |
---|
<%@ page import = "com.crystaldecisions.sdk.exception.SDKException, com.crystaldecisions.sdk.framework.*, com.crystaldecisions.sdk.occa.infostore.*, com.crystaldecisions.sdk.occa.report.*, com.crystaldecisions.sdk.properties.*, java.util.*" %> <% // 用户登录信息 IEnterpriseSession enterpriseSession = null; // 登陆系统 // 循环所有对象 for(Iterator boCount = boInfoObjects.iterator() ; boCount.hasNext() ; ) { IInfoObject boObject = (IInfoObject)boCount.next(); out.println("Removing Session for User " + boObject.getTitle() + "</br>"); } %> |
移除所有指定类型别名 |
---|
<%@ page import = "com.crystaldecisions.sdk.exception.SDKException, com.crystaldecisions.sdk.framework.*, com.crystaldecisions.sdk.occa.infostore.*, com.crystaldecisions.sdk.occa.report.*, com.crystaldecisions.sdk.properties.*, com.crystaldecisions.sdk.plugin.desktop.user.*, java.util.*" %> <% // 用户登录信息 IEnterpriseSession enterpriseSession = null; // 登陆系统 // 查询初始ID for(;;) { // 循环除去 Administrator and Guest 的对象 // 没有结果,处理结束 if(boInfoObjects.size() == 0) break; for(Iterator boCount = boInfoObjects.iterator() ; boCount.hasNext() ; ) { IInfoObject boObject = (IInfoObject)boCount.next(); IUser boUser = (IUser)boObject; Iterator boIterator = boUser.getAliases().iterator(); while(boIterator.hasNext()) { IUserAlias boAlias = (IUserAlias)boIterator.next(); String authentication = boAlias.getAuthentication(); // 如果是secLDAP的别名,则删除 // 可能的别名类型为 "secWinAD", "secEnterprise", "secWindowsNT", "secLDAP" if("secLDAP".equals(authentication)) { boUser.getAliases().remove(boAlias); } } max_id = boObject.getID(); } infoStore.commit(boInfoObjects); } %> |
变更用户为命名用户或并行用户 |
---|
<%@ page import = "com.crystaldecisions.sdk.exception.SDKException, com.crystaldecisions.sdk.framework.*, com.crystaldecisions.sdk.occa.infostore.*, com.crystaldecisions.sdk.occa.report.*, com.crystaldecisions.sdk.properties.*, com.crystaldecisions.sdk.plugin.desktop.user.*, com.crystaldecisions.sdk.plugin.desktop.usergroup.*, java.util.*" %> <% // 用户登录信息 int boConnectionType = 1; // 设为 1 (并行用户), 0 (命名用户) String groupName = "Everyone"; IEnterpriseSession enterpriseSession = null; // 登陆系统 // 取得用户组 if(boInfoObjects.size() == 0) // 没有用户组返回,退出 } else { IUserGroup currentGroup = (IUserGroup)boInfoObjects.get(0); //取得游标对象 Set boUserList = currentGroup.getUsers(); IInfoObjects boInfoObjects2 = (IInfoObjects)infoStore.query("Select * FROM CI_SYSTEMOBJECTS WHERE SI_ID = " + boUserIterator.next()); IUser boUser = (IUser)boInfoObjects2.get(0); // Administrator or Guest 除外 if (!(boUser.getTitle().equals("Administrator") || boUser.getTitle().equals("Guest"))) { boUser.setConnection(boConnectionType); if (boConnectionType == 1) { out.println("Set " + boUser.getTitle() + " user account to Concurrent </br>"); } else { out.println("Set " + boUser.getTitle() + " user account to Named </br>"); } } infoStore.commit(boInfoObjects2); } } %> |
添加用户别名 |
---|
<%@ page import = "com.crystaldecisions.sdk.exception.SDKException, com.crystaldecisions.sdk.framework.*, com.crystaldecisions.sdk.occa.infostore.*, com.crystaldecisions.sdk.occa.report.*, com.crystaldecisions.sdk.properties.*, com.crystaldecisions.sdk.plugin.desktop.user.*, com.crystaldecisions.sdk.plugin.desktop.usergroup.*, java.util.*" %> <% // 用户登录信息 String groupName = "Everyone"; // 变更所属用户组名 IEnterpriseSession enterpriseSession = null; // 登陆系统 // 取得用户组 if(boInfoObjects.size() == 0) // 没有用户组信息,返回 } else { IUserGroup currentGroup = (IUserGroup)boInfoObjects.get(0); //取得游标对象 Set boUserList = currentGroup.getUsers(); IInfoObjects boInfoObjects2 = (IInfoObjects)infoStore.query("Select * FROM CI_SYSTEMOBJECTS WHERE SI_ID = " + boUserIterator.next()); IUser boUser = (IUser)boInfoObjects2.get(0); // Administrator or Guest 除外 if (!(boUser.getTitle().equals("Administrator") || boUser.getTitle().equals("Guest"))) { IUserAliases boAliases = boUser.getAliases(); IUserAlias myAlias = boAliases.addExisting(AliasType + ":" + boUser.getTitle(),AliasType + ":#" + boUser.getID(), isDisabled); } infoStore.commit(boInfoObjects2); } } %> |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
12 | |
9 | |
9 | |
8 | |
6 | |
6 | |
6 | |
6 | |
5 |