Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Purge users under /home and copy protected nodes

samthadhani
Level 3
Level 3

Hi,

We have a requirement where user can change their email addresses which is being primarily used for their login to cq. The users are first created in LDAP and they synced with CQ and that is when we create users under /home/... /user . We also create sub-nodes beneath the user node for saving some of their profile items.

So when the user changes their email and verify themselves, i want to create a new usernode with their new email and purge the last used email and before i purge that account i want to copy their profile items to the new user node but these items are protected. I tried doing copy by JcrUtil but that fails.

The solution that i am thinking is to read the properties from those protected nodes and copy them to new usernode but i want to avoid doing that. Is there any other solution to achieve it and purging protected nodes. PS: I don't want to disable the user i want to purge them.

1 Accepted Solution
samthadhani
Correct answer by
Level 3
Level 3

samthadhani wrote...

Hi,

We have a requirement where user can change their email addresses which is being primarily used for their login to cq. The users are first created in LDAP and they synced with CQ and that is when we create users under /home/... /user . We also create sub-nodes beneath the user node for saving some of their profile items.

So when the user changes their email and verify themselves, i want to create a new usernode with their new email and purge the last used email and before i purge that account i want to copy their profile items to the new user node but these items are protected. I tried doing copy by JcrUtil but that fails.

The solution that i am thinking is to read the properties from those protected nodes and copy them to new usernode but i want to avoid doing that. Is there any other solution to achieve it and purging protected nodes. PS: I don't want to disable the user i want to purge them.

 

I have found the solution to remove the user

But i am still looking for moving the protected nodes.

Session jcrSession = resourceResolver.adaptTo(Session.class);
            UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
            Authorizable authorizable = userManager.getAuthorizable("userName");
            if (authorizable instanceof User) {
                User user = (User)authorizable;
                user.remove(); //to remove

                user.disable() // will disable the user.
            }

View solution in original post

6 Replies
samthadhani
Correct answer by
Level 3
Level 3

samthadhani wrote...

Hi,

We have a requirement where user can change their email addresses which is being primarily used for their login to cq. The users are first created in LDAP and they synced with CQ and that is when we create users under /home/... /user . We also create sub-nodes beneath the user node for saving some of their profile items.

So when the user changes their email and verify themselves, i want to create a new usernode with their new email and purge the last used email and before i purge that account i want to copy their profile items to the new user node but these items are protected. I tried doing copy by JcrUtil but that fails.

The solution that i am thinking is to read the properties from those protected nodes and copy them to new usernode but i want to avoid doing that. Is there any other solution to achieve it and purging protected nodes. PS: I don't want to disable the user i want to purge them.

 

I have found the solution to remove the user

But i am still looking for moving the protected nodes.

Session jcrSession = resourceResolver.adaptTo(Session.class);
            UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
            Authorizable authorizable = userManager.getAuthorizable("userName");
            if (authorizable instanceof User) {
                User user = (User)authorizable;
                user.remove(); //to remove

                user.disable() // will disable the user.
            }

John_Ky
Level 2
Level 2

Hi samthadhani 

I got the same problem,

Please help to share how can you solve it?

Thank you

samthadhani
Level 3
Level 3

John Ky wrote...

Hi samthadhani 

I got the same problem,

Please help to share how can you solve it?

Thank you

 

Hey John,

You can't move the node/properties that are protected. I am not sure what specific problem you have. Do you bother explaining a bit further? 

Cheers

John_Ky
Level 2
Level 2

Hi samthadhani 

Below is my original question, is it similar to yours?

Thank you samthadhani .

 

"""" How to change login username with carry all relevant data of that user?

Currently I want to allow the users can update their username (default is email), but when tried to research for some documents and forum topics I have not find out yet how to implement it.
The adobe CQ system do use the username for creating a node under /home/users/** and other places under /content/usergenerated/**.
Programmatically, what should we do to let the api update or create new username node and migrate all relevant data to the new name?
Please help to advice how to deal with this require. """"

[img]user_node_data.png[/img]

[img]usergenerated_data.png[/img]

[img]How_to_change_username.png[/img]

samthadhani
Level 3
Level 3

John Ky wrote...

Hi samthadhani 

Below is my original question, is it similar to yours?

Thank you samthadhani .

 

"""" How to change login username with carry all relevant data of that user?

Currently I want to allow the users can update their username (default is email), but when tried to research for some documents and forum topics I have not find out yet how to implement it.
The adobe CQ system do use the username for creating a node under /home/users/** and other places under /content/usergenerated/**.
Programmatically, what should we do to let the api update or create new username node and migrate all relevant data to the new name?
Please help to advice how to deal with this require. """"

 

Hey John,

Changing the user name isn't possible. What you can do is, generate a random unique username for every unique email id and maintain them either in DB or ldap, if you don't want to use email id. 

CQ5 recognizes anything as username it is not necessary to provide email id as username.  Check Ldap documentation for more details. I think the parameter was memberId or uniqueMemberID in case of LDAP. If you implementing your own API's then then you will have to sync users manually. LDAP does that for you automatically with a flag.

I was using ldap in my use case.

Cheers,

Sam

John_Ky
Level 2
Level 2

Thanks so much for your help.

I will try to suggest the client try to not use email as the username.

Best regards,

John