Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2011 ConnId (connid-dev@googlegroups.com) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.connid.bundles.ad;
 
 import java.util.List;
 import java.util.Map;
 
 public class ADConfiguration extends LdapConfiguration {
 
     private boolean ssl = true;
 
     private boolean retrieveDeletedUser = true;
 
     private boolean retrieveDeletedGroup = true;
 
     public static final String PROMPT_USER_FLAG = "pwdLastSet";
 
     public static final String PROMPT_USER_VALUE = "0";
 
     public static final String LOCK_OUT_FLAG = "lockoutTime";
 
     public static final String LOCK_OUT_DEFAULT_VALUE = "0";
 
     public static final String UCCP_FLAG = "userCannotChangePassword";
 
     public static final String CN_NAME = "CN";
 
     private List<Stringmemberships;
 
     private boolean trustAllCerts;
 
     private boolean membershipsInOr = false;
 
     private boolean startSyncFromToday = true;
 
     private String defaultPeopleContainer;
 
     private String defaultGroupContainer;
 
     private SearchScope userSearchScope;
 
     private SearchScope groupSearchScope;
 
     private String groupSearchFilter;
 
     private String[] groupBaseContexts = {};
 
     private String[] userBaseContexts = {};
 
     private String groupMemberReferenceAttribute = "member";
 
     private String groupOwnerReferenceAttribute = "managedBy";
 
     private boolean pwdUpdateOnly = false;
 
             .,
             CollectionUtil.newList("top""person""organizationalPerson""user"),
             false,
             CollectionUtil.newList("sAMAccountName""cn""member"),
             .);
 
             .,
             CollectionUtil.newList("top""group"),
             false,
             Collections.<String>emptyList());
 
     public ADConfiguration() {
         super();
 
         setUidAttribute("sAMAccountName");
         setSynchronizePasswords(false);
         setAccountUserNameAttributes("sAMAccountName");
         setObjectClassesToSynchronize(new String[] { "user" });
        setGroupMemberAttribute("member");
        setUsePagedResultControl(true);
        setBlockSize(100);
        setUseBlocks(true);
        setPasswordAttribute("unicodePwd");
        setPort(636);
         = new ArrayList<String>();
    }
    @Override
    @ConfigurationProperty(displayMessageKey = "ssl.display",
            helpMessageKey = "ssl.help", order = 1)
    public boolean isSsl() {
        return ;
    }
    @Override
    public void setSsl(final boolean ssl) {
        super.setSsl(ssl);
        this. = ssl;
    }
    @Override
        result.put(.getObjectClass(), );
        result.put(.getObjectClass(), );
        return result;
    }
    @ConfigurationProperty(displayMessageKey = "memberships.display",
            helpMessageKey = "memberships.help", order = 1)
    public String[] getMemberships() {
        return .toArray(new String[.size()]);
    }
    public void setMemberships(String... memberships) {
        this. = new ArrayList<String>();
        if (memberships != null) {
            for (String membership : memberships) {
                this..add(membership.trim());
            }
        }
    }
    @ConfigurationProperty(displayMessageKey = "retrieveDeletedUser.display",
            helpMessageKey = "retrieveDeletedUser.help", order = 2)
    public boolean isRetrieveDeletedUser() {
        return ;
    }
    public void setRetrieveDeletedUser(boolean retrieveDeletedUser) {
        this. = retrieveDeletedUser;
    }
    @ConfigurationProperty(displayMessageKey = "retrieveDeletedGroup.display",
            helpMessageKey = "retrieveDeletedGroup.help", order = 3)
    public boolean isRetrieveDeletedGroup() {
        return this.;
    }
    public void setRetrieveDeletedGroup(boolean retrieveDeletedGroup) {
        this. = retrieveDeletedGroup;
    }
    @ConfigurationProperty(displayMessageKey = "trustAllCerts.display",
            helpMessageKey = "trustAllCerts.help", order = 4)
    public boolean isTrustAllCerts() {
        return ;
    }
    public void setTrustAllCerts(final boolean trustAllCerts) {
        this. = trustAllCerts;
    }
    public boolean isMembershipsInOr() {
        return ;
    }
    @ConfigurationProperty(displayMessageKey = "membershipsInOr.display",
            helpMessageKey = "membershipsInOr.help", order = 5)
    public void setMembershipsInOr(boolean membershipsInOr) {
        this. = membershipsInOr;
    }
    @ConfigurationProperty(order = 6, required = true,
            displayMessageKey = "baseContextsToSynchronize.display",
            helpMessageKey = "baseContextsToSynchronize.help")
    @Override
    public String[] getBaseContextsToSynchronize() {
        return super.getBaseContextsToSynchronize();
    }
    @Override
    public void setBaseContextsToSynchronize(String... baseContextsToSynchronize) {
        super.setBaseContextsToSynchronize(baseContextsToSynchronize);
    }
    @ConfigurationProperty(displayMessageKey = "defaultPeopleContainer.display",
            helpMessageKey = "defaultPeopleContainer.help", order = 7)
    public String getDefaultPeopleContainer() {
        if (StringUtil.isBlank()) {
            return getBaseContextsToSynchronize() == null || getBaseContextsToSynchronize().length < 1
                    ? null : getBaseContextsToSynchronize()[0];
        } else {
            return ;
        }
    }
    public void setDefaultPeopleContainer(String defaultPeopleContainer) {
        this. = defaultPeopleContainer;
    }
    @ConfigurationProperty(displayMessageKey = "defaultGroupContainer.display",
            helpMessageKey = "defaultGroupContainer.help", order = 8)
    public String getDefaultGroupContainer() {
        if (StringUtil.isBlank()) {
            return getBaseContextsToSynchronize() == null || getBaseContextsToSynchronize().length < 1
                    ? null : getBaseContextsToSynchronize()[0];
        } else {
            return ;
        }
    }
    public void setDefaultGroupContainer(String defaultGroupContainer) {
        this. = defaultGroupContainer;
    }
    @ConfigurationProperty(displayMessageKey = "userSearchScope.display",
            helpMessageKey = "userSearchScope.help", order = 9)
    public String getUserSearchScope() {
        return  == null ? ..toString() : .toString();
    }
    public void setUserSearchScope(final String userSearchScope) {
        this. = SearchScope.valueOf(userSearchScope.toLowerCase());
    }
    @ConfigurationProperty(displayMessageKey = "groupSearchScope.display",
            helpMessageKey = "groupSearchScope.help", order = 10)
    public String getGroupSearchScope() {
        return  == null ? ..toString() : .toString();
    }
    public void setGroupSearchScope(final String groupSearchScope) {
        this. = SearchScope.valueOf(groupSearchScope.toLowerCase());
    }
    @ConfigurationProperty(displayMessageKey = "groupSearchFilter.display",
            helpMessageKey = "groupSearchFilter.help", order = 11)
    public String getGroupSearchFilter() {
        return ;
    }
    public void setGroupSearchFilter(String groupSearchFilter) {
        this. = groupSearchFilter;
    }
    @ConfigurationProperty(displayMessageKey = "groupBaseContexts.display",
            helpMessageKey = "groupBaseContexts.help", order = 12)
    public String[] getGroupBaseContexts() {
        if ( != null && . > 0) {
            // return specified configuration
            return .clone();
        } else {
            // return root suffixes
            return getBaseContextsToSynchronize();
        }
    }
    public void setGroupBaseContexts(String... baseContexts) {
        this. = baseContexts.clone();
        // update base context everytime ...
        super.setBaseContexts(this.getBaseContexts());
    }
    @ConfigurationProperty(displayMessageKey = "userBaseContexts.display",
            helpMessageKey = "userBaseContexts.help", order = 13)
    public String[] getUserBaseContexts() {
        if ( != null && . > 0) {
            // return specified configuration
            return .clone();
        } else {
            // return root suffixes
            return getBaseContextsToSynchronize();
        }
    }
    public void setUserBaseContexts(final String... baseContexts) {
        this. = baseContexts.clone();
        // update base context everytime ...
        super.setBaseContexts(this.getBaseContexts());
    }
    @Override
    public String[] getBaseContexts() {
        final List<Stringres = new ArrayList<String>();
        res.addAll(Arrays.asList(getUserBaseContexts()));
        res.addAll(Arrays.asList(getGroupBaseContexts()));
        return res.toArray(new String[res.size()]);
    }
    @ConfigurationProperty(displayMessageKey = "groupMemberReferenceAttribute.display",
            helpMessageKey = "groupMemberReferenceAttribute.help", order = 14)
        return StringUtil.isBlank() ? "member" : ;
    }
    public void setGroupMemberReferenceAttribute(String groupMemberReferenceAttribute) {
        this. = groupMemberReferenceAttribute;
    }
    @ConfigurationProperty(displayMessageKey = "groupOwnerReferenceAttribute.display",
            helpMessageKey = "groupOwnerReferenceAttribute.help", order = 15)
        return StringUtil.isBlank() ? "managedBy" : ;
    }
    public void setGroupOwnerReferenceAttribute(String groupOwnerReferenceAttribute) {
        this. = groupOwnerReferenceAttribute;
    }
    @ConfigurationProperty(displayMessageKey = "startSyncFromToday.display",
            helpMessageKey = "startSyncFromToday.help", order = 16)
    public boolean isStartSyncFromToday() {
        return ;
    }
    public void setStartSyncFromToday(boolean startSyncFromToday) {
        this. = startSyncFromToday;
    }
    public boolean isPwdUpdateOnly() {
        return ;
    }
    @ConfigurationProperty(displayMessageKey = "pwdUpdateOnly.display",
            helpMessageKey = "pwdUpdateOnly.help", required = true, order = 17)
    public void setPwdUpdateOnly(boolean pwdUpdateOnly) {
        this. = pwdUpdateOnly;
    }
    @Override
    public final void setUidAttribute(final String uidAttribute) {
        setAccountUserNameAttributes("sAMAccountName"uidAttribute);
        super.setUidAttribute(uidAttribute);
    }
    public enum SearchScope {
        object,
        onelevel,
        subtree
    }
New to GrepCode? Check out our FAQ X