Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Retrieve List of users from DefaultDom using API

Avatar

Level 2

Hello All,

I know that we get retrieve list of users from a Group using findGroupMembers(). Is there any way that I can fetch the list of users who are part of DefaultDom using adobe provided API's?

Requesting help as I am not able to find any helpful info on this.

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Employee

ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);

            DirectoryManagerServiceClient dirClient = new DirectoryManagerServiceClient(myFactory);

            PrincipalSearchFilter psf = new PrincipalSearchFilter();

            psf.setSpecificDomainName("DefaultDom") ;

            psf.setPrincipalType(UMConstants.PrincipalTypes.PRINCIPALTYPE_USER);

            psf.setRetrieveOnlyActive();

        

            List<PrincipalReference> principalList = dirClient.findPrincipals(psf);

            Iterator pit = principalList.iterator();

            String oid = "";

            User testUser = null;

            while (pit.hasNext()){

                 testUser = (User)(pit.next());

                 System.out.println(testUser.getCommonName());

            }

View solution in original post

6 Replies

Avatar

Correct answer by
Employee

ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);

            DirectoryManagerServiceClient dirClient = new DirectoryManagerServiceClient(myFactory);

            PrincipalSearchFilter psf = new PrincipalSearchFilter();

            psf.setSpecificDomainName("DefaultDom") ;

            psf.setPrincipalType(UMConstants.PrincipalTypes.PRINCIPALTYPE_USER);

            psf.setRetrieveOnlyActive();

        

            List<PrincipalReference> principalList = dirClient.findPrincipals(psf);

            Iterator pit = principalList.iterator();

            String oid = "";

            User testUser = null;

            while (pit.hasNext()){

                 testUser = (User)(pit.next());

                 System.out.println(testUser.getCommonName());

            }

Avatar

Level 2

Hi Aditya,

Thanks for the answer. Your code is working prefect.

My requirement is that, we have our livecycle setup in ES 2.5. Now that we are migrating the application from ES2.5 to ES4, we need to manually create the list of users in DefaultDom.

Could you please let me know if Is there any way that I can export the list of users to other version?

Thanks.

Avatar

Employee

There is no default way.

When you are migrating application, that is not upgrading es2.5 TO es4. You are doing it manually. The user migration happens as the part of DB migration, as user/ groups & their information resides in LC DB. Having said that, AD users can be synced to new environment, but as such there is no way to do the same for local users.  It all depends on the number of local users you have. If the number is large enough and you want to import you can do it from API, but that is just an approach not recommended. ( there are constraints like -there are groups too - import the groups first, then users, then update their group membership etc. 2) when you migrate users you have to give new password - as you cannot retrieve old password , so all users will have a new default password) 3) if above two constraints can be overlooked for testing applications, you can further check the API. export groups list - import groups. export users & get user membership too- import users - update user membership if any ( info like email account etc will still be missed, so it needs to be taken care of) Otherwise if local users number is not large enough & if you have just one environment- manual operation is recommended.

Avatar

Level 2

Hi Aditya,

Thanks for your help. I missed mentioning upgrading instead of migrating the applications.

As of now we need only the list of users in the new version(ES4). It will be of great help if you can provide any code snippet for exporting and importing the user list as I am relatively new to java.

Many Thanks.

Avatar

Level 2

Hi Aditya,

I was able to export the list of users in DefaultDom. However, I was able to do only for 10 entries which I think is a limitation as is the case with "FindUsers" operation.

Is there any way that I can retrieve list of all users who are part of that domain?

Thanks.