如何使用 cognos SDK 更新 Cognos 数据源的密码?

How do I update the password for a Cognos Data Source with the cognos SDK?

如何使用 Cognos SDK v10.2 以编程方式执行与 How do I update the password for a Cognos Data Source? 中相同的操作?

我从来没有找到如何只更新密码,但我可以重新创建包含我的密码的 DataSourceSignon,这足以满足我的需要。请注意,这可能会重置 DataSourceSignon 中的其他内容。

他们展示了如何在 http://www-01.ibm.com/support/docview.wss?uid=swg21370529

中创建这些 DataSourceSignon

要重新创建 DataSourceSignon,您只需创建第二次即可,它将覆盖第一次。

这是我解决这个问题的方法。 this.getCMService() returns ContentManagerService_PortType

的对象在哪里
public boolean updateSignOn(final String dataSourceName, final String connectionName,
        final String signOnName, final String user, final String password) {

    final String connectionSearchPath = "CAMID(\":\")/dataSource[@name='" + dataSourceName
            + "']/dataSourceConnection[@name='" + connectionName + "']";
    final PropEnum props[] = {PropEnum.defaultName, PropEnum.user, PropEnum.credentials,
            PropEnum.searchPath, PropEnum.version, PropEnum.consumers};

    try {
        // Create a new signon
        final DataSourceSignon newdsSignon = new DataSourceSignon();
        final BaseClassArrayProp cons = new BaseClassArrayProp();
        final BaseClass[] oConsumers = new BaseClass[1];
        final Nil c1 = new Nil();
        final StringProp sp = new StringProp();
        // If you want a specific user/group to have access to the signon,
        // change the search path to that user/group search path
        sp.setValue("CAMID(\"::Everyone\")");
        c1.setSearchPath(sp);
        oConsumers[0] = c1;
        cons.setValue(oConsumers);
        // Set everyone to have access to the signon
        newdsSignon.setConsumers(cons);

        // Add credentials to the signon
        final AnyTypeProp credentials = new AnyTypeProp();
        final String credString = "<credential><username>" + user + "</username><password>"
                + password + "</password></credential>";
        credentials.setValue(credString);
        // Replace previous 3 lines with the next commented line,
        // if you want to use the same credentials as another existing signon
        // credentials.setValue(dts);
        newdsSignon.setCredentials(credentials);

        final TokenProp tp = new TokenProp();
        tp.setValue(signOnName);
        newdsSignon.setDefaultName(tp);

        final SearchPathMultipleObject dsConnSearchPobj = new SearchPathMultipleObject(
                connectionSearchPath);

        final BaseClass bc[] = this.getCMService().query(dsConnSearchPobj, props, new Sort[] {},
                new QueryOptions());
        final BaseClassArrayProp bcap = new BaseClassArrayProp();
        bcap.setValue(bc);
        newdsSignon.setParent(bcap);

        final AddOptions ao = new AddOptions();
        ao.setUpdateAction(UpdateActionEnum.replace);

        final SearchPathSingleObject newObject = new SearchPathSingleObject();
        newObject.set_value((bc[0]).getSearchPath().getValue());

        this.getCMService().add(newObject, new BaseClass[] {newdsSignon}, ao);
        System.out.println("DataSource: " + dataSourceName + "\nConnection: " + connectionName
                + "\nSignOn: " + signOnName + " was updated");
    } catch (final Exception e) {
        System.out.println(e);
        return false;
    }

    return true;
}