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

Purge users under /home and copy protected nodes

Avatar

Former Community Member

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

Avatar

Correct answer by
Former Community Member

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

Avatar

Correct answer by
Former Community Member

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.
            }

Avatar

Level 2

Hi samthadhani 

I got the same problem,

Please help to share how can you solve it?

Thank you

Avatar

Former Community Member

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

Avatar

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]

Avatar

Former Community Member

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

Avatar

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 

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----