내 커뮤니티 업적 표시줄을 확대합니다.

The first preview of our new Community upgrade is live - check it out now.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Programatic user creation in AEM

Avatar

Level 3

I am using the below code to create users under /home/users/myproject

Session session = request.getResourceResolver().adaptTo(Session.class);
        //Session session2  = request.get 
        JackrabbitSession jsession= (JackrabbitSession) session;
        UserManager usermanager;
        final String  userName = "testincdscdcg2ss2dcd3";
        try {
            usermanager = (UserManager) js.getUserManager();
            User user = usermanager.createUser("Mytestissng2dcddcdxsx", "dcdMyTestingsvdfcdv2", new Principal() {

                        public String getName() {
                            return userName;
                        }
                    }, "/home/users/myproject");
            jsession.save();

 

But it is creating users with strange node names, Attached is the screen shot. Even if i create a user from AEM useradmin UI it creates users with similar strange node names. 

Just wondering how does geometrixx has user nodes with proper names under /home/users/geometrixx.

Also once the new user node is created under my project path i.e  /home/users/myproject/ppXn-NUF084WwcxjAD9 i need to add a profile node and add some properties using below code

String NodePath = userManager.getAuthorizable("Mytestissng2dcddcdxsx ").getPath()

Node node = session.getNode(NodePath );

/* Add profile node and add properies to profile node like profileNode.setProperty("timeNow", System.currentTimeMillis()); */

 

but userManager.getAuthorizable("Mytestissng2dcddcdxsx ").getPath(); is saying The method getPath() is undefined for the type Authorizable. Is there a way i can get the node name from usermanager api by passing the username of the user as a parameter ?

As i don't have control over the node name that is getting created i am not able frame a path like " /home/users/myproject/+nodenameoftheuser " and then test if one such node exists and get that node using the path Session.getNode( " /home/users/myproject/+nodenameoftheuser ") 

Any help is appreciated.

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Level 10

It is the actual behavior of AEM in its latest versions. So you will have to use queries to get the path

원본 게시물의 솔루션 보기

2 답변 개

Avatar

Employee

Hi,

please see an earlier thread on how AEM 6.1 now creates the path for users:

http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage...

Regards,

Opkar

Avatar

정확한 답변 작성자:
Level 10

It is the actual behavior of AEM in its latest versions. So you will have to use queries to get the path