| | |
| | | updateServerGroup(ALL_SERVERGROUP_NAME, serverGroupProperties); |
| | | |
| | | // Update the server property "GROUPS" |
| | | Set rawGroupList = (Set) serverProperties.get(ServerProperty.GROUPS); |
| | | Set<?> rawGroupList = (Set<?>) |
| | | serverProperties.get(ServerProperty.GROUPS); |
| | | Set<String> groupList = new HashSet<String>(); |
| | | if (rawGroupList != null) { |
| | | for (Object elm : rawGroupList.toArray()) { |
| | |
| | | // Unregister the server in server groups |
| | | try |
| | | { |
| | | NamingEnumeration ne; |
| | | NamingEnumeration<SearchResult> ne; |
| | | SearchControls sc = new SearchControls(); |
| | | |
| | | String serverID = getServerID(serverProperties); |
| | |
| | | ne = dirContext.search(getServerGroupContainerDN(), filter, sc); |
| | | while (ne.hasMore()) |
| | | { |
| | | SearchResult sr = (SearchResult)ne.next(); |
| | | SearchResult sr = ne.next(); |
| | | String groupDn = sr.getNameInNamespace(); |
| | | BasicAttribute newAttr = new BasicAttribute(memberAttrName); |
| | | NamingEnumeration attrs = sr.getAttributes().getAll(); |
| | | NamingEnumeration<? extends Attribute> attrs = |
| | | sr.getAttributes().getAll(); |
| | | while (attrs.hasMore()) |
| | | { |
| | | Attribute attr = (Attribute)attrs.next(); |
| | | Attribute attr = attrs.next(); |
| | | String attrID = attr.getID(); |
| | | |
| | | if (attrID.equalsIgnoreCase(memberAttrName)) |
| | | { |
| | | NamingEnumeration ae = attr.getAll(); |
| | | NamingEnumeration<?> ae = attr.getAll(); |
| | | while (ae.hasMore()) |
| | | { |
| | | String value = (String)ae.next(); |
| | |
| | | return result; |
| | | } |
| | | Attributes attrs = srs.next().getAttributes(); |
| | | NamingEnumeration ne = attrs.getAll(); |
| | | NamingEnumeration<? extends Attribute> ne = attrs.getAll(); |
| | | while (ne.hasMore()) |
| | | { |
| | | Attribute attr = (Attribute)ne.next(); |
| | |
| | | } |
| | | |
| | | // We have the members list |
| | | NamingEnumeration ae = attr.getAll(); |
| | | NamingEnumeration<?> ae = attr.getAll(); |
| | | while (ae.hasMore()) |
| | | { |
| | | result.add((String)ae.next()); |
| | |
| | | new HashSet<Map<ServerProperty,Object>>(); |
| | | try |
| | | { |
| | | NamingEnumeration ne; |
| | | NamingEnumeration<SearchResult> ne; |
| | | SearchControls sc = new SearchControls(); |
| | | |
| | | sc.setSearchScope(SearchControls.ONELEVEL_SCOPE); |
| | | ne = dirContext.search(getServerContainerDN(), "(objectclass=*)", sc); |
| | | while (ne.hasMore()) |
| | | { |
| | | SearchResult sr = (SearchResult)ne.next(); |
| | | SearchResult sr = ne.next(); |
| | | Map<ServerProperty,Object> properties = |
| | | makePropertiesFromServerAttrs(sr.getAttributes()); |
| | | Object keyId = properties.get(ServerProperty.INSTANCE_KEY_ID); |
| | |
| | | new HashSet<Map<ServerGroupProperty, Object>>(); |
| | | try |
| | | { |
| | | NamingEnumeration ne; |
| | | NamingEnumeration<SearchResult> ne; |
| | | SearchControls sc = new SearchControls(); |
| | | |
| | | sc.setSearchScope(SearchControls.ONELEVEL_SCOPE); |
| | |
| | | sc); |
| | | while (ne.hasMore()) |
| | | { |
| | | SearchResult sr = (SearchResult)ne.next(); |
| | | SearchResult sr = ne.next(); |
| | | Map<ServerGroupProperty, Object> properties = |
| | | makePropertiesFromServerGroupAttrs(sr.getAttributes()); |
| | | result.add(properties); |
| | |
| | | Set<Map<AdministratorProperty, Object>> result = |
| | | new HashSet<Map<AdministratorProperty, Object>>(); |
| | | try { |
| | | NamingEnumeration ne; |
| | | NamingEnumeration<SearchResult> ne; |
| | | SearchControls sc = new SearchControls(); |
| | | |
| | | sc.setSearchScope(SearchControls.ONELEVEL_SCOPE); |
| | |
| | | sc); |
| | | while (ne.hasMore()) |
| | | { |
| | | SearchResult sr = (SearchResult)ne.next(); |
| | | SearchResult sr = ne.next(); |
| | | |
| | | Map<AdministratorProperty, Object> properties = |
| | | makePropertiesFromAdministratorAttrs( |
| | |
| | | */ |
| | | public void removeAdminData() throws ADSContextException |
| | | { |
| | | LdapName dn = nameFromDN(getServerContainerDN()); |
| | | String[] dns = {getServerContainerDN(), |
| | | getServerGroupContainerDN(), |
| | | getInstanceKeysContainerDN(), |
| | | getAdministratorContainerDN()}; |
| | | try |
| | | { |
| | | Control[] controls = new Control[] { new SubtreeDeleteControl() }; |
| | | LdapContext tmpContext = dirContext.newInstance(controls); |
| | | try |
| | | { |
| | | tmpContext.destroySubcontext(dn); |
| | | for (String dn : dns) |
| | | { |
| | | LdapName ldapName = nameFromDN(dn); |
| | | if (isExistingEntry(ldapName)) |
| | | { |
| | | tmpContext.destroySubcontext(dn); |
| | | } |
| | | } |
| | | } |
| | | finally |
| | | { |
| | | tmpContext.close(); |
| | | } |
| | | // Recreate the container entries: |
| | | createContainerEntry(getServerContainerDN()); |
| | | createContainerEntry(getServerGroupContainerDN()); |
| | | createContainerEntry(getInstanceKeysContainerDN()); |
| | | } |
| | | catch(NamingException x) |
| | | { |
| | |
| | | |
| | | // if modification includes 'privilege', we have to get first the |
| | | // current privileges list. |
| | | NamingEnumeration currentPrivileges = null; |
| | | NamingEnumeration<?> currentPrivileges = null; |
| | | if (adminProperties.containsKey(AdministratorProperty.PRIVILEGE)) |
| | | { |
| | | SearchControls sc = new SearchControls(); |
| | | sc.setSearchScope(SearchControls.OBJECT_SCOPE); |
| | | String[] attList = {"ds-privilege-name"}; |
| | | sc.setReturningAttributes(attList); |
| | | NamingEnumeration ne = dirContext.search( |
| | | NamingEnumeration<SearchResult> ne = dirContext.search( |
| | | dnCentralAdmin, "(objectclass=*)", sc); |
| | | SearchResult sr = (SearchResult)ne.next(); |
| | | SearchResult sr = ne.next(); |
| | | |
| | | currentPrivileges = sr.getAttributes().get("ds-privilege-name") |
| | | .getAll(); |
| | |
| | | */ |
| | | private static BasicAttributes makeAttrsFromAdministratorProperties( |
| | | Map<AdministratorProperty, Object> adminProperties, |
| | | boolean passwordRequired, NamingEnumeration currentPrivileges) |
| | | boolean passwordRequired, NamingEnumeration<?> currentPrivileges) |
| | | throws ADSContextException |
| | | { |
| | | BasicAttributes attrs = new BasicAttributes(); |
| | |
| | | } |
| | | } |
| | | |
| | | LinkedList privileges = (LinkedList) |
| | | LinkedList<?> privileges = (LinkedList<?>) |
| | | adminProperties.get(AdministratorProperty.PRIVILEGE); |
| | | for( Object o : privileges) |
| | | { |
| | |
| | | break; |
| | | case GROUPS: |
| | | result = new BasicAttribute(ServerProperty.GROUPS.getAttributeName()); |
| | | for (Object o : ((Set) value)) { |
| | | for (Object o : ((Set<?>) value)) { |
| | | result.add(o); |
| | | } |
| | | break; |
| | |
| | | case MEMBERS: |
| | | result = new BasicAttribute( |
| | | ServerGroupProperty.MEMBERS.getAttributeName()); |
| | | for (Object o : ((Set) value)) { |
| | | for (Object o : ((Set<?>) value)) { |
| | | result.add(o); |
| | | } |
| | | break; |
| | |
| | | { |
| | | |
| | | Set<String> set = new HashSet<String>(); |
| | | NamingEnumeration ae = attr.getAll(); |
| | | NamingEnumeration<?> ae = attr.getAll(); |
| | | while (ae.hasMore()) |
| | | { |
| | | set.add((String)ae.next()); |
| | |
| | | new HashMap<ServerProperty, Object>(); |
| | | try |
| | | { |
| | | NamingEnumeration ne = attrs.getAll(); |
| | | NamingEnumeration<? extends Attribute> ne = attrs.getAll(); |
| | | while (ne.hasMore()) |
| | | { |
| | | Attribute attr = (Attribute)ne.next(); |
| | | Attribute attr = ne.next(); |
| | | String attrID = attr.getID(); |
| | | Object value; |
| | | |
| | |
| | | if (attr.size() >= 1 && MULTIVALUED_SERVER_PROPERTIES.contains(prop)) |
| | | { |
| | | Set<String> set = new HashSet<String>(); |
| | | NamingEnumeration ae = attr.getAll(); |
| | | NamingEnumeration<?> ae = attr.getAll(); |
| | | while (ae.hasMore()) |
| | | { |
| | | set.add((String)ae.next()); |
| | |
| | | else if (attrID.equalsIgnoreCase("ds-privilege-name")) |
| | | { |
| | | LinkedHashSet<String> privileges = new LinkedHashSet<String>(); |
| | | NamingEnumeration attValueList = attr.getAll(); |
| | | NamingEnumeration<?> attValueList = attr.getAll(); |
| | | while (attValueList.hasMoreElements()) |
| | | { |
| | | privileges.add(attValueList.next().toString()); |