user3764852
user3764852

Reputation: 21

WAS 7.0 Create users and map role to users wtih wsadmin

I have a requirement to create userids and assign Admin role for some users and I am trying to do this through a Jython script as it will speed up the process and saves time. So,I have created the below Jython script to achieve it.

Script

import sys


filename="C:\Users\harish\Desktop\scripts\input.txt"
fileread = open(filename, 'r')

filelines = fileread.readlines()  

for row in filelines:  
   column=row.strip().split(';')
   user_name=column[0]
   print user_name  
   pass_word=column[1]  
   first=column[2]  
   last=column[3]  
   AdminTask.createUser(['-uid',user_name, '-password', pass_word, '-confirmPassword', pass_word, '-  cn', first, '-sn', last ])

   AdminTask.mapUsersToAdminRole(['-roleName','Administrator','-userids',user_name])

   AdminConfig.save()

   print 'Userid creation completed for', user_name

fileread.close()

The script runs fine and doesn't throw any errors.However, the users are not able to login to WAS Admin Console and they can only able to do it after I save the configuration by clicking "OK" at page "Users and Groups" -> "Administrative User Roles" ->

Can someone please let me know what am I missing here while working with wsadmin or is there anything else I need to do to accomplish the task ?

I am working on WAS 8.5.5.0 version.

Thanks for your help.

Upvotes: 1

Views: 2929

Answers (1)

David KUNTZ
David KUNTZ

Reputation: 61

I think you need to add this code to the end of your script (not in the for-loop). This will refresh the security configuration.

agmBean = AdminControl.queryNames('type=AuthorizationGroupManager,process=dmgr,*')
AdminControl.invoke(agmBean, 'refreshAll')

This assumes you're using Network Deployment, process=dmgr. You may need to change the process.

Upvotes: 2

Related Questions