script to add users to the Administrator group. Is there any better approach?
Author: rinku_chowdhury
Publication Date: 6/6/2018 15:52
Sometime users get removed from the Administrator Group, hence the plan is to run a script to add users to that group without doing it manually. here below is my initial approach.
Or any function that will give access to act as an admin to the following instructions?
element = context.getStoreElement ();
Connection con = element.getProject ().getConnection ();
Project project = con.getProjectById (pid);
List <Group> prGroup = project.getGroups ();
List <User> prUser = project.getUsers ();
List <User> adminUser = new ArrayList <User> (int i);
adminUser.add (prUser.get (int i)); // loop to add
User [] adminUsers = adminUser.toArray (new User [adminUser.size ()]); // conversion
// as the current user doesnt have admin permission hence running this method will throw Target exception: java.lang.SecurityException
project.lock ();
prGroup.get (int adminIndex) .addUsers (adminUser);
project.save ();
project.unlock ();
con.disconnet ();
Tags: beanshell, java, java-client, script
-
Author: tenter - 6/13/2018 16:00
Hi RInku,
I'm afraid I didn't understand your question - I would expect that you need an admin user in order to add people to an admin group. Is this your problem?
Regards,
Hannes
0 -
Author: rinku_chowdhury - 6/15/2018 9:38
Hi Hannes,
Is it possible that a user with no admin permission can have a connection to FS server as an admin (with credentials) and then add users to the administrator group? I am writing a script for such scenario. I have tried connectionManager.getConnection(parameters) / connection.getAdminService() to connect as an admin but somehow not working. have I explained clearly? please do let me know if you need more info.0 -
Author: pavone - 6/22/2018 13:13
Hi Rinku,
which FirstSpirit version du you use?
ConnectionManager.getConnection should work. Are you sure the user you use to connect is at least a project level admin?
Regards,
Tim
0 -
Author: sebastianc - 7/5/2018 16:05
Hi Rinku,
do you need further help or did Tims's reply already help you? If so, it would be great if you marked his reply as "correct answer" so that other community users find the solution easily. If you have already found a solution by yourself, it would be very kind of you, if you posted it here.Best regards
Sebastian
0 -
Author: rinku_chowdhury - 7/13/2018 9:56
Hi Tim,
thanks for the clue. It works.0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
5 Kommentare