#1 2024-04-11 14:24:56

marcioribeiro1979
Member
Registered: 2023-04-18

Creating users manually

Hi,

I´m creating an user manually , like this:

import net.datenwerke.security.service.usermanager.entities.User

User newUser = new User();
newUser.setFirstname("test");
newUser.setLastname("test2");
newUser.setUsername("test");
newUser.setEmail("test@test");
                       
What is the easiest way to add this user in "/usermanager/external" folder ?

I read the documentation and example for ldap legacy import, however in the example the loop is in SearchResult, like this:

for(SearchResult sr : searchResults.values()){

And I´m looping the entries, like this:

for (SearchResultEntry result1 : searchResult.getSearchEntries())


Thanks,

Offline

#2 2024-04-16 10:52:05

Felix
Moderator
Registered: 2022-08-01

Re: Creating users manually

hi marcioribeiro,

you can search for an "ou" (organizational unit aka folder) and set this as parent of the new user wink

UserManagerService userManagerService = GLOBALS.getRsService(UserManagerService.class);
List<OrganisationalUnit> ouList = userManagerService.getOUsByName("myFolder");
newUser .setParent(ouList[0]);
try{
     userManagerService.persist(newUser );
  }catch ( Exception ex ) {
    tout.println("persisting $user failed: $ex")
  }	

Softwareentwickler bei Infofabrik

Offline

Board footer

Powered by FluxBB