While adding new user in crowd this error may appear when you accidently attempt to create new user in Active Directory(LDAP).
INFO: [LDAP: error code 53 - 0000001F: SvcErr: DSID-031A0FC0, problem 5003 (WILL_NOT_PERFORM), data 0
]; nested exception is javax.naming.OperationNotSupportedException: [LDAP: error code 53 - 0000001F: SvcErr: DSID-031A0FC0, problem 5003 (WILL_NOT_PERFORM), data 0
]; remaining name 'cn=newtestuser,cn=users,dc=vantage,dc=com'
Solution :
If you dont want to add new user in Active Directory then you can:
Remove 'Add User' permission from Active directory in your crowd application settings:
1) Goto Aplications list in crowd server.
2) Select your application..
3)Select Permissions tab.
4)Select Active directory from the list of directories in your application.
5)Uncheck Add User.
6) Click Update.
Make sure you have other directories in the list with 'Add User' permission.
Showing posts with label atlassian-crowd. Show all posts
Showing posts with label atlassian-crowd. Show all posts
Crowd : Getting all users removing duplicates in an application using Crowd REST java client
- //your crowd server settings
- String url = "http://auth.staging.company.com/crowd/";//crowd base url
- String applicationName = "appincrowd";
- String applicationPass = "apppassword";
- String groupName = "usergroup";//a user group under the app
- CrowdClient client = new RestCrowdClientFactory().newInstance(url, applicationName, applicationPass);
- //initialze crowd client
- //a single user can be more than one group,so let's remove duplicate users by using Set
- Set<CrowdUser> allCrowdUsers = new HashSet<>();
- List<String> newGroupList = client.searchGroupNames(NullRestrictionImpl.INSTANCE, 0, maxGroupSearchResult);
- //get all users in a single list
- for (String currGroupName : newGroupList) {
- List<User> currGroupUsers = client.getUsersOfGroup(currGroupName, 0, maxUserSearchResult);
- for (User grpUser : currGroupUsers) {
- allCrowdUsers.add(new CrowdUser(grpUser));
- }
- }
- //traverse the all users list
- for (User usr : allCrowdUsers) {
- System.out.println(usr.getName() + " " + usr.getFirstName() + " " + usr.getLastName() + " (" + usr.getEmailAddress() + ")");
- }
Output:
- //john cooper (cooper@company.com)
- //sam peters (sam@company.com)
- //...............................
- //Istiak Ahmad (iask@company.com)
Extended crowd user class:
CrowdUser.java:
- import com.atlassian.crowd.model.user.User;
- import com.atlassian.crowd.model.user.UserTemplate;
- /**
- *Extend user with overridden equals() and hashCode() method according to user email address so that we can build a collection(Set<>) with no different users with same email address
- *
- */
- public class CrowdUser extends UserTemplate {
- public CrowdUser(User user) {
- super(user);
- }
- /**
- compare only user email address
- */
- @Override
- public boolean equals(Object object) {
- boolean result = false;
- if (object == null || object.getClass() != getClass()) {
- result = false;
- } else {
- CrowdUser muser = (CrowdUser) object;
- if (this.getEmailAddress().compareTo(muser.getEmailAddress()) == 0) {
- result = true;
- }
- }
- return result;
- }
- // only email address
- @Override
- public int hashCode() {
- return this.getEmailAddress().hashCode();
- }
- }
Creating/registering new user in Crowd with Crowd REST java client
Put the dependecy in your pom.xml
<dependency>
<groupId>com.atlassian.crowd.client</groupId>
<artifactId>atlassian-crowd-rest-client</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.atlassian.crowd.client</groupId>
<artifactId>atlassian-crowd-rest-client</artifactId>
<version>1.1</version>
</dependency>
In your java code:
- import com.atlassian.crowd.embedded.api.PasswordCredential;
- import com.atlassian.crowd.exception.ApplicationPermissionException;
- import com.atlassian.crowd.exception.GroupNotFoundException;
- import com.atlassian.crowd.exception.InvalidAuthenticationException;
- import com.atlassian.crowd.exception.OperationFailedException;
- import com.atlassian.crowd.model.user.*;
- import com.atlassian.crowd.exception.UserNotFoundException;
- import com.atlassian.crowd.service.client.CrowdClient;
- import com.atlassian.crowd.integration.rest.service.factory.RestCrowdClientFactory;
- import com.atlassian.crowd.service.client.ClientPropertiesImpl;
- import com.atlassian.crowd.service.client.ClientResourceLocator;
public static int registerNewUser(String userName, String emailAddress, String password) {
//your crowd server settings String url = "http://auth.staging.company.com/crowd/";//crowd base url String applicationName = "appincrowd"; String applicationPass = "apppassword"; String groupName = "usergroup";//a user group under the app CrowdClient client = new RestCrowdClientFactory().newInstance(url, applicationName, applicationPass); //initialze crowd client UserTemplate ut = new UserTemplate(userName); ut.setActive(true);//make it active ut.setEmailAddress(emailAddress); ut.setName(userName); PasswordCredential p = new PasswordCredential(password, false); client.addUser(ut, p); client.addUserToGroup(userName, groupName);//now add user to that group
}
Setting Crowd configuration with properties :
Instead of hard-coded crowd configuration we should read them from a properties file:
Properties crowdProp=//properties from your bean ClientPropertiesImpl newCrowdClient=ClientPropertiesImpl.newInstanceFromProperties(crowdProp); CrowdClient client = new RestCrowdClientFactory().newInstance(newCrowdClient);
Labels:
API,
atlassian-crowd,
java,
Single-Sign-On,
spring-security
Subscribe to:
Posts (Atom)