使用IBM VMM在Custom Federal Repository中创建用户

时间:2017-11-02 16:15:54

标签: java websphere single-sign-on websphere-8 virtual-member-manager

我正在尝试使用IBM Virtual Member Manager API(Java代码)在自定义LDAP存储库(Ex:RepositoryID = custpmRepo)中创建新用户。尝试使用IBM代码创建用户。但这是在默认存储库中创建用户(defaultWIMFileBasedRealm- InternalFileRepository)。

IBM Docs转介 https://www.ibm.com/support/knowledgecenter/SSAW57_8.0.0/com.ibm.websphere.wim.doc/programmingprereq.html https://www.ibm.com/support/knowledgecenter/SSAW57_8.0.0/com.ibm.websphere.wim.doc/samplecodeforworkingwithusersandgroups.html

有人可以指导我如何使用VMM API(Java代码)在自定义LDAP存储库中创建用户。 下面是我用来创建用户的代码

public static void addPersonAccount(String uid, String cn, String sn)
{
    System.out.println("****#### UserAndGroupSample - addPersonAccount - Entering Method");
    try
    {
        locateService(EJB_JNDI_NAME);
        DataObject root = SDOHelper.createRootDataObject();
        DataObject entity = SDOHelper.createEntityDataObject(root, null, 
                SchemaConstants.DO_PERSON_ACCOUNT);
        entity.set("uid", uid);
        entity.set("cn", cn);
        System.out.println("Input data graph before creating user"+ printDO(root));
        // Create the PersonAccount entity
        root = service.create(root);
        System.out.println("Output data graph after creating user"+ printDO(root));
    }
    catch(Exception e)
    {
        System.out.println("Exception: " + e.getMessage());
        e.printStackTrace();
    }

    System.out.println("****#### UserAndGroupSample - addPersonAccount - Exiting Method");
}

1 个答案:

答案 0 :(得分:0)

通过设置父级,可以设置以下属性以在所需的自定义LDAP存储库(默认父级或不同的OrgContainer下)中创建用户 user.createDataObject(DO_PARENT).createDataObject(DO_IDENTIFIER).setString(PROP_UNIQUE_NAME,parentDN) 其中parentDN是父级的uniqueName,例如,o = LDAP或ou = sample,o = defaultWIMFileBasedRealm