Tag Archives: jython

Adding EMPLOYEE_EXTENDED to all users

Today i read a question in the IBM Connections Forum about setting the EMPLOYEE_EXTENDED role to all users in a Connections deployment. It would be easy to set it directly in the database, but that’s not supported by IBM.

I wrote a little script some weeks ago, because i had the same request, but never published it. The good thing here it only uses supported commands.

So i use this question to add it as a new script to my GitHub Repository.

Here you see the source, it is simple a join of the tables emp_role_map and employee:

connect to peopledb;
EXPORT TO mail.txt OF DEL MODIFIED by NOCHARDEL
select e.PROF_MAIL FROM EMPINST.EMPLOYEE e
    inner join EMPINST.EMP_ROLE_MAP r
    on r.PROF_KEY=e.PROF_KEY
    where r.ROLE_ID!='employee.extended';
connect reset;

Just call it with db2 -tvf scriptname.sql.

The script exports a list of mail addresses of users without the specified role. This can then be used with the wsadmin command ProfilesService.setBatchRole(EMPLOYEE_EXTENDED, "mail.txt").

wsadmin.bat -lang jython -c 'ProfilesService.setBatchRole(EMPLOYEE_EXTENDED, "mail.txt")' as a oneliner will update the roles.

Scheduling the two commands with Windows Scheduler or cron is enough to update all users to the specified role.

Documentation is provided in the script head.

New version of “Administration Scripts for WebSphere”

As preparation for Social Connections VI in Prague next week i redesigned the “Administration Scripts for IBM Websphere“.

Some highlights:

  • all scripts are moved to a subfolder with DMGR/bin (folder name: ibmcnx)
  • tested in multinode environments
  • added some classes everybody can use for his own scripts
  • adding policies to libraries (personal and communities) are using search now

New scripts:

  • documentation of all jvm settings of each application server
  • create a file with all documentation in one step
  • create cluster members for additional nodes

Sharon created a document with the content of all of our presentations and collected several tipps all around connections and community scripts. She will share this next time. We started to share parts of this document and more documentations (installation, usage) for scripts and IBM Connections on:

Scripting101.org

The new version can be downloaded from:

Last weeks, new scripts and next weeks

It was little bit quiet here after Connect 2014. I had lots of projects and no time to add new scripts or even do bug fixing.

I promised at Connect, that i will fix the JDBC drivers, that they will load on Windows too. See cnxMemberCheckExIDByEmail.py as an example.

Loading JDBC Drivers within jython scripts

Jan Riedel sent me a solution for SLES and i tested his proposal today within Windows. He points me in the right direction, i mustn’t load the path or jar within the script, it is better to load on starting wsadmin. You have to add the JDBC Driver path to WAS_EXT_DIRS.

I see two ways here:

Change setupCmdLine.sh|bat (Update)

I don’t like to change setupCmdLine directly, because i don’t want to load the driver everytime i start wsadmin or WebSphere, but you can add your JDBC path to the line

set WAS_EXT_DIRS=….;c:\ibm\jdbc (Windows)
export WAS_EXT_DIRS=….:/opt/IBM/JDBC (Linux)

Please do not change your setupCmdLine in this way. I had errors on using Connections updateInstaller, when i use it! Use WAS_USER_SCRIPT!

Add a WAS_USER_SCRIPT

I create a batch|shell script with following content.

wasuserscript.sh

Create the script in $WAS_HOME/profiles/Dmgr01/bin and make it executable.

export WAS_EXT_DIRS=$WAS_EXT_DIRS:/opt/IBM/JDBC

wasuserscript.bat

Create batch in %WAS_HOME%\profiles\Dmgr01\bin

set WAS_EXT_DIRS=%WAS_EXT_DIRS;c:\IBM\JDBC

Now it is enough to set the environment variable WAS_USER_SCRIPT, then the jdbc driver will be loaded on wsadmin start. So when you want to load cnxmenu.py or one of the scripts using JDBC ( cnxMemberCheckExIDByEmail.py, cnxMemberDeactAndActByEmail.py) simply set the WAS_USER_SCRIPT variable in your operating system, terminal or console.

export WAS_USER_SCRIPT=/opt/IBM/.../wasuserscript.sh

or

set WAS_USER_SCRIPT=C:\....\wasuserscript.bat

Thanks to Victor Toal for your script testing and bug reporting!

New scripts

I added some scripts for special j2ee roles to the github repository:

  • cfgJ2EERoleGlobalModerator.py
  • cfgJ2EERoleMetricsReader.py
  • cfgJ2EERoleMetricsReportRun.py
  • cfgJ2EERoleSocialMail.py

These scripts set consistent the roles mentioned in the file name. So you can enable or disable Socialmail integration, Metrics or Moderation.

Next weeks, next events

Next events i will attend are: Engage in Breda, BCCON in Hamburg and Social Connections VI in Prag.

At Engage i will speak with my friend Sharon Bellamy about Scripting.

At BCCON i will be with my swiss friend and scripting colleague Klaus Bild, we will do the Script show in german.

I plan a session for SocCon VI too, hope i will get a slot there.

New OpenNTF.org project: Administration Scripts for WebSphere

I started a new project on OpenNTF for the collection of scripts we created to speed up and simplify WebSphere and Connections Administration.

Link to this project: Administration Scripts for WebSphere

In the moment most of documentation is only as comment in these scripts. Descriptions can be found in Github and Slideshare.

Highlights

  • J2EE Security Role Backup and Restore
  • Set initial Security Roles for Connections Applications (Author: Klaus Bild)

Documentation

When you want to start with this collection, copy the jython script to your Deployment Manager bin-folder ($WAS_HOME/profiles/Dmgr01/bin) and call the scripts with wsadmin.sh -f scriptname

I will create more documentation in the next days. Please use the slideshare documents and icon uk presentation to begin using and coding jython.

Dannotes

I will presentate some of these scripts on 50. Dannotes on Thursday 28th November in Korsør.

SocCnx: more scripts added

Because of a delay of some hours on my flight back from Social Connections V on saturday, i had time to rewrite the jython script for backing up and restore security roles in WebSphere Application Server.

I updated the master branch on GitHub, which now contains a db2 initscript and the two new scripts securityrolebackup.py and securityrolerestore.py!

You can call the scripts through wsadmin.sh|bat and they do following.

securityrolebackup.sh

cd $WAS_HOME/profiles/Dmgr01/bin
./wsadmin.sh -lang jython -username admin -password password -f "path/securityrolebackup.sh" "../temp"

This will save the security roles for each installed application to $WAS_HOME/profiles/Dmgr01/temp to single files named: Application.txt.

securityrolerestore.sh

cd $WAS_HOME/profiles/Dmgr01/bin
./wsadmin.sh -lang jython -username admin -password password -f "path/securityrolerestore.sh" "../temp"

This will take the backups from $WAS_HOME/profiles/Dmgr01/temp and restore all access rights in the single applications. All applications will be restored, but you can change the script for one or some of the applications, when you change from line 49:

49 apps = AdminApp.list()
50 appsList = apps.split(lineSeparator)
51 # Test with some Apps:
52 # appsList = ['Blogs','Activities','Wikis']
53 # or Single App:
54 # appsList = ['Blogs']

Comment out line 49 and 50, and remove # from line 52 to restore only some Application security roles, or remove # from 54 to restore only one!

Tipp

I had several updates and cr installations with IBM Connections the last years and on some of these the updateinstaller removes my configured security roles. Now you can backup before and restore after installing a fix.

Disclaimer

These scripts are provided as is, with no warranties, and confers no rights! Please test them before using in production environments.