Compare commits

...
This repository has been archived on 2021-03-03. You can view files and clone it, but cannot push or open issues or pull requests.

3 Commits

3 changed files with 23 additions and 10 deletions

View File

@ -21,7 +21,7 @@
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="owner.project.facets" value="java"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>

View File

@ -11,7 +11,7 @@
<groupId>org.gcube.portal</groupId>
<artifactId>ldap-export-servlet</artifactId>
<packaging>war</packaging>
<version>1.2.1</version>
<version>1.3.0</version>
<name>ldap-export-servlet Maven Webapp</name>
<description>This component read periodically exports users and their groups in LDAP</description>
<properties>

View File

@ -103,11 +103,11 @@ public class LDAPSync implements Runnable {
_log.debug("Initiating LDAP Sync ...");
createUsersOrganizationalUnit(ctx);
//crate or update the whole list of organizations (objectClass=organizationalUnit, ou="+orgName+",dc=d4science,dc=org) and groups ( objectClass=top and POSIXGroup)
updateGroups(ctx, rootVO);
//and update the users list
//update the users list
exportSingleUsers(ctx, env, users);
//crate or update the whole list of organizations (objectClass=organizationalUnit, ou="+orgName+",dc=d4science,dc=org) and groups ( objectClass=top and POSIXGroup)
updateGroups(ctx, rootVO);
} catch (NamingException e) {
_log.error("Something went Wrong during LDAP Sync in Exporting to LDAP");
e.printStackTrace();
@ -134,6 +134,8 @@ public class LDAPSync implements Runnable {
attributes.put(description);
// private static final String USER_CONTEXT = ",";
ctx.createSubcontext("ou=Organizations,dc=d4science,dc=org", attributes);
_log.info("organizationalUnit \"ou=Organizations,dc=d4science,dc=org\" created");
attributes = new BasicAttributes();
objectClass = new BasicAttribute("objectClass");
@ -141,6 +143,7 @@ public class LDAPSync implements Runnable {
attributes.put(objectClass);
description.add("Default Organization");
ctx.createSubcontext("o=D4Science,ou=Organizations,dc=d4science,dc=org", attributes);
_log.info("organizationalUnit \"o=D4Science,ou=Organizations,dc=d4science,dc=org\" created");
attributes = new BasicAttributes();
objectClass = new BasicAttribute("objectClass");
@ -148,6 +151,7 @@ public class LDAPSync implements Runnable {
attributes.put(objectClass);
description.add("People Org Unit");
ctx.createSubcontext("ou=People,o=D4Science,ou=Organizations,dc=d4science,dc=org", attributes);
_log.info("organizationalUnit \"ou=People,o=D4Science,ou=Organizations,dc=d4science,dc=org\" created");
}
else
_log.info("ou=Organizations,dc=d4science,dc=org already present, skip");
@ -176,6 +180,7 @@ public class LDAPSync implements Runnable {
updateUsersInGroup(ctx, vreSubCtx, vre);
}
}
_log.debug("LDAP Groups Sync Completed OK!");
}
/**
*
@ -201,7 +206,14 @@ public class LDAPSync implements Runnable {
Attributes attributes = new BasicAttributes();
attributes.put(memberUid);
ctx.modifyAttributes(vreSubCtx, DirContext.ADD_ATTRIBUTE, attributes);
_log.info("Adding user: " + user);
_log.info("Adding user as memberUid: " + user );
Attribute member = new BasicAttribute("member");
member.add(getSubContext(user));
Attributes attributes2 = new BasicAttributes();
attributes2.put(member);
ctx.modifyAttributes(vreSubCtx, DirContext.ADD_ATTRIBUTE, attributes2);
_log.info("Adding user as memberUid: " + user );
}
catch (javax.naming.directory.AttributeInUseException ex) {
_log.trace("Not adding already existing user: " + user);
@ -259,9 +271,9 @@ public class LDAPSync implements Runnable {
Attribute objectClass = new BasicAttribute("objectClass");
objectClass.add("top");
objectClass.add("groupofnames");
objectClass.add("posixGroup");
// objectClass.add("researchProject");
// objectClass.add("groupOfMembers");
//objectClass.add("nestedGroup");
attributes.put(objectClass);
Attribute cn = new BasicAttribute("cn");
@ -363,6 +375,7 @@ public class LDAPSync implements Runnable {
objectClass.add("posixAccount");
objectClass.add("organizationalPerson");
objectClass.add("person");
objectClass.add("inetUser");
objectClass.add("shadowAccount");
objectClass.add("ldapPublicKey");
attributes.put(objectClass);