Refine search
final Entry e = it.next(); ldapEntry.setDn(e.getDn().getName()); ldapEntry.setBindPrincipal(e.getDn().getName()); for (Attribute attribute : e.getAttributes()) { if (activeDirectory && "userPrincipalName".equalsIgnoreCase(attribute.getId())) { ldapEntry.setBindPrincipal(attribute.getString()); if (attribute.isHumanReadable()) { ldapEntry.put(attribute.getId(), Joiner.on(", ").join(attribute.iterator())); if ("memberOf".equalsIgnoreCase(attribute.getId()) || "isMemberOf".equalsIgnoreCase(attribute.getId())) { for (Value<?> group : attribute) { groupDns.add(group.getString()); final Attribute groupId = group.get(groupIdAttribute); LOG.trace("Resolved {} to group {}", groupDn, groupId); if (groupId != null) {
for (Entry e : groupSearch) { if (LOG.isTraceEnabled()) { LOG.trace("Group Entry: {}", e.toString(" ")); if (! e.containsAttribute(groupIdAttribute)) { LOG.warn("Unknown group id attribute {}, skipping group entry {}", groupIdAttribute, e); continue; final String groupId = e.get(groupIdAttribute).getString(); if (ldapEntry == null) { if (e.hasObjectClass("groupOfUniqueNames")) { memberAttribute = ATTRIBUTE_UNIQUE_MEMBER; } else if (e.hasObjectClass("groupOfNames") || e.hasObjectClass("group")) { memberAttribute = ATTRIBUTE_MEMBER; } else if (e.hasObjectClass("posixGroup")) { memberAttribute = ATTRIBUTE_MEMBER_UID; } else { if (e.containsAttribute(ATTRIBUTE_UNIQUE_MEMBER)) { memberAttribute = ATTRIBUTE_UNIQUE_MEMBER; } else if (e.containsAttribute(ATTRIBUTE_MEMBER_UID)) { memberAttribute = ATTRIBUTE_MEMBER_UID; } else { final Attribute members = e.get(memberAttribute); if (members != null) { final String dn = normalizedDn(ldapEntry.getDn());
String oid = getOid( entry, SchemaConstants.MATCHING_RULE, schemaManager.isStrict() ); if ( !schemaManager.isSchemaLoaded( schemaName ) ) String msg = I18n.err( I18n.ERR_16028_CANNOT_ADD_MR, entry.getDn().getName(), schemaName ); LOG.info( I18n.err( I18n.ERR_16029_CANNOT_ADD_MR_IN_REGISTRY, entry.getDn().getName(), schemaName ) ); schema = schemaManager.getLoadedSchema( schemaName ); Attribute mSyntax = entry.get( MetaSchemaConstants.M_SYNTAX_AT ); matchingRule.setSyntaxOid( mSyntax.getString() );
/** * Process the FQCN attribute * * @param entry The entry to read * @param objectType The type of schema object * @return The schema object FQCN * @throws LdapInvalidAttributeValueException If the attribute does not contain a valid value */ private String getFqcn( Entry entry, String objectType ) throws LdapInvalidAttributeValueException { // The FQCN Attribute mFqcn = entry.get( MetaSchemaConstants.M_FQCN_AT ); if ( mFqcn == null ) { String msg = I18n.err( I18n.ERR_16034_ENTRY_WITHOUT_VALID_AT, objectType, MetaSchemaConstants.M_FQCN_AT ); if ( LOG.isWarnEnabled() ) { LOG.warn( msg ); } throw new IllegalArgumentException( msg ); } return mFqcn.getString(); }
private void addMemberToRoleOrGroup(final CoreSession session, final String dn, final String memberDN, final String attributeName) throws LdapException { final Entry entry = session.lookup(new Dn(dn), attributeName); Attribute attribute = entry.get(attributeName); if (attribute == null) { entry.add(attributeName, memberDN); attribute = entry.get(attributeName); } else { attribute.add(memberDN); } final ModifyRequestImpl modifyRequestImpl = new ModifyRequestImpl(); modifyRequestImpl.setName(entry.getDn()); modifyRequestImpl.replace(attribute); session.modify(modifyRequestImpl); }
groups.add(cursor.get().get(configuration.getGroupNameAttribute()).getString()); Optional<SingularityUser> result = Optional.of(new SingularityUser(user, com.google.common.base.Optional.fromNullable(Strings.emptyToNull(userEntry.get(configuration.getUserNameAttribute()).getString())), com.google.common.base.Optional.fromNullable(Strings.emptyToNull(userEntry.get(configuration.getUserEmailAttribute()).getString())), groups));
throw new IllegalArgumentException( I18n.err( I18n.ERR_16016_NULL_ENTRY ) ); if ( entry.get( SchemaConstants.CN_AT ) == null ) throw new IllegalArgumentException( I18n.err( I18n.ERR_16017_INVALID_CN_AT ) ); name = entry.get( SchemaConstants.CN_AT ).getString(); if ( entry.get( SchemaConstants.CREATORS_NAME_AT ) == null ) throw new IllegalArgumentException( I18n.err( I18n.ERR_16018_INVALID_AT, SchemaConstants.CREATORS_NAME_AT ) ); owner = entry.get( SchemaConstants.CREATORS_NAME_AT ).getString(); if ( entry.get( MetaSchemaConstants.M_DISABLED_AT ) != null ) String value = entry.get( MetaSchemaConstants.M_DISABLED_AT ).getString(); value = Strings.upperCase( value ); isDisabled = "TRUE".equalsIgnoreCase( value ); if ( entry.get( MetaSchemaConstants.M_DEPENDENCIES_AT ) != null ) Attribute depsAttr = entry.get( MetaSchemaConstants.M_DEPENDENCIES_AT ); depsSet.add( value.getValue() );
@NotNull private ExternalIdentity createIdentity(@NotNull Entry entry, @Nullable String id, boolean isGroup) throws LdapInvalidAttributeValueException { LdapProviderConfig.Identity cfg = isGroup ? config.getGroupConfig() : config.getUserConfig(); if (id == null) { String idAttribute = cfg.getIdAttribute(); Attribute attr = entry.get(idAttribute); if (attr == null) { throw new LdapInvalidAttributeValueException(ResultCodeEnum.CONSTRAINT_VIOLATION, "no value found for attribute '" + idAttribute + "' for entry " + entry); } id = attr.getString(); } String extId = config.getUseUidForExtId() ? id : entry.getDn().getName(); ExternalIdentityRef ref = new ExternalIdentityRef(extId, this.getName()); String path = cfg.makeDnPath() ? createDNPath(entry.getDn()) : null; LdapIdentity identity = isGroup ? new LdapGroup(this, ref, id, path, entry) : new LdapUser(this, ref, id, path, entry); Map<String, Object> props = identity.getProperties(); applyAttributes(props, entry); return identity; }
private void removeMemberFromRoleOrGroup(final CoreSession session, final String dn, final String memberDN, final String attributeName) throws LdapException { final Entry entry = session.lookup(new Dn(dn), attributeName); final Attribute attribute = entry.get(attributeName); if (attribute != null) { attribute.remove(memberDN); final ModifyRequestImpl modifyRequestImpl = new ModifyRequestImpl(); modifyRequestImpl.setName(entry.getDn()); modifyRequestImpl.replace(attribute); session.modify(modifyRequestImpl); } }
private void denormalizeEntryOpAttrs( Entry entry ) throws LdapException { if ( directoryService.isDenormalizeOpAttrsEnabled() ) { Attribute attr = entry.get( SchemaConstants.CREATORS_NAME_AT ); if ( attr != null ) { Dn creatorsName = dnFactory.create( attr.getString() ); attr.clear(); attr.add( denormalizeTypes( creatorsName ).getName() ); } attr = entry.get( SchemaConstants.MODIFIERS_NAME_AT ); if ( attr != null ) { Dn modifiersName = dnFactory.create( attr.getString() ); attr.clear(); attr.add( denormalizeTypes( modifiersName ).getName() ); } attr = entry.get( ApacheSchemaConstants.SCHEMA_MODIFIERS_NAME_AT ); if ( attr != null ) { Dn modifiersName = dnFactory.create( attr.getString() ); attr.clear(); attr.add( denormalizeTypes( modifiersName ).getName() ); } } }
public void move( MoveOperationContext moveContext, Entry entry, boolean cascade ) throws LdapException { Attribute oc = entry.get( objectClassAT ); for ( Value value : oc ) { String oid = schemaManager.getObjectClassRegistry().getOidByName( value.getValue() ); if ( objectClass2synchronizerMap.containsKey( oid ) ) { RegistrySynchronizer synchronizer = objectClass2synchronizerMap.get( oid ); synchronizer.move( moveContext.getDn(), moveContext.getNewSuperior(), entry, cascade ); return; } } if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) ) { schemaSynchronizer.move( moveContext.getDn(), moveContext.getNewSuperior(), entry, cascade ); return; } throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM ); }
/** * Update the Operational Attribute with the reference to the subentry */ private void setOperationalAttribute( Entry entry, Dn subentryDn, AttributeType opAttr ) throws LdapException { Attribute operational = entry.get( opAttr ); if ( operational == null ) { operational = new DefaultAttribute( opAttr ); entry.put( operational ); } operational.add( subentryDn.getName() ); }
/** * Update the list of modifications with a modification associated with a specific * role, if it's requested. */ private void getOperationalModForReplace( boolean hasRole, AttributeType attributeType, Entry entry, Dn oldDn, Dn newDn, List<Modification> modifications ) throws LdapInvalidAttributeValueException { String oldDnStr = oldDn.getName(); String newDnStr = newDn.getName(); if ( hasRole ) { Attribute operational = entry.get( attributeType ).clone(); if ( operational == null ) { operational = new DefaultAttribute( attributeType, newDnStr ); } else { operational.remove( oldDnStr ); operational.add( newDnStr ); } modifications.add( new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, operational ) ); } }
Dn dn = new Dn(accountDN); EntryCursor cursor = connection.search(dn, accountDN, SearchScope.ONELEVEL, (String[])null); if (cursor.next()) { for (Attribute attr : entry.getAttributes()) { String id = attr.getId(); List<String> values; if (account.containsKey(id)) { values = new ArrayList<String>(); values.add(attr.get().getValue().toString()); account.put(id, values);
Attribute oc = entry.get( objectClassAT ); String oid = schemaManager.getObjectClassRegistry().getOidByName( value.getValue() ); if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) ) if ( oc.contains( SchemaConstants.ORGANIZATIONAL_UNIT_OC ) ) if ( deleteContext.getDn().size() != 3 ) String ouValue = deleteContext.getDn().getRdn().getValue(); ouValue = Strings.toLowerCaseAscii( Strings.trim( ouValue ) );
/** * Get keys. * @throws IOException e * @return keys */ public List<EncryptionKey> getKeys() throws IOException { Iterator<Value> iterator1 = entry.get(KerberosAttribute.KRB5_KEY_AT).iterator(); List<EncryptionKey> keys = new ArrayList<>(); while (iterator1.hasNext()) { byte[] encryKey = iterator1.next().getBytes(); EncryptionKey key = new EncryptionKey(); key.decode(encryKey); key.setKvno(1); // TODO: kvno should be correctly stored and retrieved keys.add(key); } return keys; }