We are trying to run a script via url to create new users , we are able to execute the code via the same but users are not getting created in the User Management tab.
The same script is running successfully and getting users created through the RS terminal.
I have an another query , is it possible to provide apikey via the script?
Below is the script which we have used:-
import net.datenwerke.security.service.usermanager.UserManagerService;
import net.datenwerke.security.service.usermanager.entities.User;
import javax.servlet.http.HttpServletRequest
def userService = GLOBALS.getInstance(UserManagerService.class);
def user = new User();
user.setUsername("sampletest");
user.setFirstname("Paul");
user.setLastname("Testuser");
def root = userService.getRoots().get(0);
root.addChild(user);
userService.persist(user);
return "added new user";
with the terminal, you should run “exec -c script.groovy” in order to commit the changes. I guess you executed this way, since it is working on the terminal.
Are you passing this argument to the URL too ?
User user = userManagerService.getUserByName("myUser");
List<OrganisationalUnit> ouList = userManagerService.getOUsByName("myOU");
for (OrganisationalUnit ou: ouList) {
ou.addChild(user);
}
Group gr = userManagerService.getGroupByName("myGroup");
gr.addUser(user);
We are trying to use an application database users and their properties (team they belongs etc.) to compare with users in RS database.We want to know what DB is used for storing users in RS, what are impacted tables (like: users, user_organizations, maybe_some_pivot_tables etc.) or how is structured part which is impacting user authentication/authorization in RS.
The tables used are in the internal database your reportserver installation uses. You can see it under administration → datasources → datasource root → internal datasources
But you shouldn’t need this. You should just use the API.
Regarding the useradd script which we were working earlier , I have an issue that I am able to create OU and add users independently , but while trying to perform these two operation simultaneously.
Could you please provide the necessary coding for the same.
For adding a user, as you mention: https://reportserver.net/en/tutorials/tutorial-scripting/
For adding a user to an existing OU: see my post #7
For adding a new OU: new OrganisationalUnit(), and then add it to an existing node with addChild(), so, again, analogously as #7.
Now we are trying to set password by the help of script , while executing the report we are getting an error message which says “error message: No signature of method: net.datenwerke.security.service.usermanager.entities.User.setPassword() is applicable for argument types: (java.lang.String)” .
We have tried this by using the method “User.setPassword”. Is it possible to set password from within the script.
If you look into RS API, net.datenwerke.security.service.usermanager.entities.User class,
you’ll see that the method User.setPassword takes two parameters and - anyway - is not recommended:
/**
* Usually you would not want to call this directly. Use {@link UserManagerService.setPassword} instead
*
* @param password
* @param passwordHasher
*/
public void setPassword(String password, PasswordHasher passwordHasher) {
String hashedPassword = passwordHasher.hashPassword(password);
this.password = hashedPassword;
}
Hi Karolina.
I tried to understand this part of code and trying to implement after import of PasswordHasher library I have got errors.
Last error I have got is:
Clearly I am doing wrong. Thing is I would like to set user password on the fly from the script.
I would use private encryption algorhitm and string that is got I would like to set as password.
Is that possible in a way I am thinking of it?
Some data I would like to pass with HTTP request but not password itself of course (probably with JWT), and I am thinking on a way of setting password on groovy side that I could use in the future.