Java Code Examples for javax.naming.directory.Attribute#size()

The following examples show how to use javax.naming.directory.Attribute#size() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LdapSender.java    From iaf with Apache License 2.0 6 votes vote down vote up
protected XmlBuilder attributesToXml(Attributes atts)
	throws NamingException {
	XmlBuilder attributesElem = new XmlBuilder("attributes");
	
	NamingEnumeration all = atts.getAll();
	while (all.hasMore()) {
		Attribute attribute = (Attribute) all.next();
		XmlBuilder attributeElem = new XmlBuilder("attribute");
		attributeElem.addAttribute("name", attribute.getID());
		if (attribute.size() == 1 && attribute.get() != null) {
			attributeElem.addAttribute("value", attribute.get().toString());
		} else {
			NamingEnumeration values = attribute.getAll();
			while (values.hasMore()) {
				Object value = values.next();
				XmlBuilder itemElem = new XmlBuilder("item");
				itemElem.addAttribute("value", value.toString());
				attributeElem.addSubElement(itemElem);
			}
		}
		attributesElem.addSubElement(attributeElem);
	}
	return attributesElem;
}
 
Example 2
Source File: LDAPCertStore.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the values for the given attribute. If the attribute is null
 * or does not contain any values, a zero length byte array is
 * returned. NOTE that it is assumed that all values are byte arrays.
 */
private byte[][] getAttributeValues(Attribute attr)
        throws NamingException {
    byte[][] values;
    if (attr == null) {
        values = BB0;
    } else {
        values = new byte[attr.size()][];
        int i = 0;
        NamingEnumeration<?> enum_ = attr.getAll();
        while (enum_.hasMore()) {
            Object obj = enum_.next();
            if (debug != null) {
                if (obj instanceof String) {
                    debug.println("LDAPCertStore.getAttrValues() "
                        + "enum.next is a string!: " + obj);
                }
            }
            byte[] value = (byte[])obj;
            values[i++] = value;
        }
    }
    return values;
}
 
Example 3
Source File: LDAPCertStore.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the values for the given attribute. If the attribute is null
 * or does not contain any values, a zero length byte array is
 * returned. NOTE that it is assumed that all values are byte arrays.
 */
private byte[][] getAttributeValues(Attribute attr)
        throws NamingException {
    byte[][] values;
    if (attr == null) {
        values = BB0;
    } else {
        values = new byte[attr.size()][];
        int i = 0;
        NamingEnumeration<?> enum_ = attr.getAll();
        while (enum_.hasMore()) {
            Object obj = enum_.next();
            if (debug != null) {
                if (obj instanceof String) {
                    debug.println("LDAPCertStore.getAttrValues() "
                        + "enum.next is a string!: " + obj);
                }
            }
            byte[] value = (byte[])obj;
            values[i++] = value;
        }
    }
    return values;
}
 
Example 4
Source File: LDAPCertStore.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the values for the given attribute. If the attribute is null
 * or does not contain any values, a zero length byte array is
 * returned. NOTE that it is assumed that all values are byte arrays.
 */
private byte[][] getAttributeValues(Attribute attr)
        throws NamingException {
    byte[][] values;
    if (attr == null) {
        values = BB0;
    } else {
        values = new byte[attr.size()][];
        int i = 0;
        NamingEnumeration<?> enum_ = attr.getAll();
        while (enum_.hasMore()) {
            Object obj = enum_.next();
            if (debug != null) {
                if (obj instanceof String) {
                    debug.println("LDAPCertStore.getAttrValues() "
                        + "enum.next is a string!: " + obj);
                }
            }
            byte[] value = (byte[])obj;
            values[i++] = value;
        }
    }
    return values;
}
 
Example 5
Source File: LDAPCertStore.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the values for the given attribute. If the attribute is null
 * or does not contain any values, a zero length byte array is
 * returned. NOTE that it is assumed that all values are byte arrays.
 */
private byte[][] getAttributeValues(Attribute attr)
        throws NamingException {
    byte[][] values;
    if (attr == null) {
        values = BB0;
    } else {
        values = new byte[attr.size()][];
        int i = 0;
        NamingEnumeration<?> enum_ = attr.getAll();
        while (enum_.hasMore()) {
            Object obj = enum_.next();
            if (debug != null) {
                if (obj instanceof String) {
                    debug.println("LDAPCertStore.getAttrValues() "
                        + "enum.next is a string!: " + obj);
                }
            }
            byte[] value = (byte[])obj;
            values[i++] = value;
        }
    }
    return values;
}
 
Example 6
Source File: LDAPCertStore.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the values for the given attribute. If the attribute is null
 * or does not contain any values, a zero length byte array is
 * returned. NOTE that it is assumed that all values are byte arrays.
 */
private byte[][] getAttributeValues(Attribute attr)
        throws NamingException {
    byte[][] values;
    if (attr == null) {
        values = BB0;
    } else {
        values = new byte[attr.size()][];
        int i = 0;
        NamingEnumeration<?> enum_ = attr.getAll();
        while (enum_.hasMore()) {
            Object obj = enum_.next();
            if (debug != null) {
                if (obj instanceof String) {
                    debug.println("LDAPCertStore.getAttrValues() "
                        + "enum.next is a string!: " + obj);
                }
            }
            byte[] value = (byte[])obj;
            values[i++] = value;
        }
    }
    return values;
}
 
Example 7
Source File: LdapManager.java    From fess with Apache License 2.0 6 votes vote down vote up
protected void processSearchRoles(final List<SearchResult> result, final Consumer<String> consumer) throws NamingException {
    for (final SearchResult srcrslt : result) {
        final Attributes attrs = srcrslt.getAttributes();

        //get group attr
        final Attribute attr = attrs.get(fessConfig.getLdapMemberofAttribute());
        if (attr == null) {
            continue;
        }

        for (int i = 0; i < attr.size(); i++) {
            final Object attrValue = attr.get(i);
            if (attrValue != null) {
                final String entryDn = attrValue.toString();

                if (logger.isDebugEnabled()) {
                    logger.debug("entryDn: {}", entryDn);
                }
                consumer.accept(entryDn);
            }
        }
    }
}
 
Example 8
Source File: LDAPCertStore.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the values for the given attribute. If the attribute is null
 * or does not contain any values, a zero length byte array is
 * returned. NOTE that it is assumed that all values are byte arrays.
 */
private byte[][] getAttributeValues(Attribute attr)
        throws NamingException {
    byte[][] values;
    if (attr == null) {
        values = BB0;
    } else {
        values = new byte[attr.size()][];
        int i = 0;
        NamingEnumeration<?> enum_ = attr.getAll();
        while (enum_.hasMore()) {
            Object obj = enum_.next();
            if (debug != null) {
                if (obj instanceof String) {
                    debug.println("LDAPCertStore.getAttrValues() "
                        + "enum.next is a string!: " + obj);
                }
            }
            byte[] value = (byte[])obj;
            values[i++] = value;
        }
    }
    return values;
}
 
Example 9
Source File: LDAPCertStore.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the values for the given attribute. If the attribute is null
 * or does not contain any values, a zero length byte array is
 * returned. NOTE that it is assumed that all values are byte arrays.
 */
private byte[][] getAttributeValues(Attribute attr)
        throws NamingException {
    byte[][] values;
    if (attr == null) {
        values = BB0;
    } else {
        values = new byte[attr.size()][];
        int i = 0;
        NamingEnumeration<?> enum_ = attr.getAll();
        while (enum_.hasMore()) {
            Object obj = enum_.next();
            if (debug != null) {
                if (obj instanceof String) {
                    debug.println("LDAPCertStore.getAttrValues() "
                        + "enum.next is a string!: " + obj);
                }
            }
            byte[] value = (byte[])obj;
            values[i++] = value;
        }
    }
    return values;
}
 
Example 10
Source File: LdapUtils.java    From spring-ldap with Apache License 2.0 6 votes vote down vote up
/**
 * Iterate through all the values of the specified Attribute calling back to
 * the specified callbackHandler.
 * @param attribute the Attribute to work with; not <code>null</code>.
 * @param callbackHandler the callbackHandler; not <code>null</code>.
 * @since 1.3
 */
public static void iterateAttributeValues(Attribute attribute, AttributeValueCallbackHandler callbackHandler) {
	Assert.notNull(attribute, "Attribute must not be null");
	Assert.notNull(callbackHandler, "callbackHandler must not be null");

	if (attribute instanceof Iterable) {
		int i = 0;
		for (Object obj : (Iterable) attribute) {
			handleAttributeValue(attribute.getID(), obj, i, callbackHandler);
			i++;
		}
	}
	else {
		for (int i = 0; i < attribute.size(); i++) {
			try {
				handleAttributeValue(attribute.getID(), attribute.get(i), i, callbackHandler);
			} catch (javax.naming.NamingException e) {
				throw convertLdapException(e);
			}
		}
	}
}
 
Example 11
Source File: LDAPCertStore.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the values for the given attribute. If the attribute is null
 * or does not contain any values, a zero length byte array is
 * returned. NOTE that it is assumed that all values are byte arrays.
 */
private byte[][] getAttributeValues(Attribute attr)
        throws NamingException {
    byte[][] values;
    if (attr == null) {
        values = BB0;
    } else {
        values = new byte[attr.size()][];
        int i = 0;
        NamingEnumeration<?> enum_ = attr.getAll();
        while (enum_.hasMore()) {
            Object obj = enum_.next();
            if (debug != null) {
                if (obj instanceof String) {
                    debug.println("LDAPCertStore.getAttrValues() "
                        + "enum.next is a string!: " + obj);
                }
            }
            byte[] value = (byte[])obj;
            values[i++] = value;
        }
    }
    return values;
}
 
Example 12
Source File: MailValidation.java    From hop with Apache License 2.0 5 votes vote down vote up
private static ArrayList<String> getMX( String hostName ) throws NamingException {
  // Perform a DNS lookup for MX records in the domain
  Hashtable<String, String> env = new Hashtable<String, String>();
  env.put( "java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory" );
  DirContext ictx = new InitialDirContext( env );
  Attributes attrs = ictx.getAttributes( hostName, new String[] { "MX" } );
  Attribute attr = attrs.get( "MX" );

  // if we don't have an MX record, try the machine itself
  if ( ( attr == null ) || ( attr.size() == 0 ) ) {
    attrs = ictx.getAttributes( hostName, new String[] { "A" } );
    attr = attrs.get( "A" );
    if ( attr == null ) {
      throw new NamingException( BaseMessages.getString( PKG, "MailValidator.NoMatchName", hostName ) );
    }
  }

  // Huzzah! we have machines to try. Return them as an array list
  // NOTE: We SHOULD take the preference into account to be absolutely
  // correct. This is left as an exercise for anyone who cares.
  ArrayList<String> res = new ArrayList<>();
  NamingEnumeration<?> en = attr.getAll();

  while ( en.hasMore() ) {
    String x = (String) en.next();
    String[] f = x.split( " " );
    if ( f[ 1 ].endsWith( "." ) ) {
      f[ 1 ] = f[ 1 ].substring( 0, ( f[ 1 ].length() - 1 ) );
    }
    res.add( f[ 1 ] );
  }
  return res;
}
 
Example 13
Source File: MailBoxValidator.java    From spring-boot with Apache License 2.0 5 votes vote down vote up
private ArrayList getMX(String hostName) throws NamingException {
    // Perform a DNS lookup for MX records in the domain
    Hashtable env = new Hashtable();
    env.put("java.naming.factory.initial",
            "com.sun.jndi.dns.DnsContextFactory");
    DirContext ictx = new InitialDirContext(env);
    Attributes attrs = ictx.getAttributes(hostName, new String[]{"MX"});
    Attribute attr = attrs.get("MX");

    // if we don't have an MX record, try the machine itself
    if ((attr == null) || (attr.size() == 0)) {
        attrs = ictx.getAttributes(hostName, new String[]{"A"});
        attr = attrs.get("A");
        if (attr == null)
            throw new NamingException("No match for name '" + hostName
                    + "'");
    }
    // Huzzah! we have machines to try. Return them as an array list
    // NOTE: We SHOULD take the preference into account to be absolutely
    // correct. This is left as an exercise for anyone who cares.
    ArrayList res = new ArrayList();
    NamingEnumeration en = attr.getAll();

    while (en.hasMore()) {
        String mailhost;
        String x = (String) en.next();
        String f[] = x.split(" ");
        // THE fix *************
        if (f.length == 1)
            mailhost = f[0];
        else if (f[1].endsWith("."))
            mailhost = f[1].substring(0, (f[1].length() - 1));
        else
            mailhost = f[1];
        // THE fix *************
        res.add(mailhost);
    }
    return res;
}
 
Example 14
Source File: ApacheDSRootDseServlet.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException {
    try {
        resp.setContentType("text/plain");
        PrintWriter out = resp.getWriter();

        out.println("*** ApacheDS RootDSE ***\n");

        DirContext ctx = new InitialDirContext(this.createEnv());

        SearchControls ctls = new SearchControls();
        ctls.setReturningAttributes(new String[] { "*", "+" });
        ctls.setSearchScope(SearchControls.OBJECT_SCOPE);

        NamingEnumeration<SearchResult> result = ctx.search("", "(objectClass=*)", ctls);
        if (result.hasMore()) {
            SearchResult entry = result.next();
            Attributes as = entry.getAttributes();

            NamingEnumeration<String> ids = as.getIDs();
            while (ids.hasMore()) {
                String id = ids.next();
                Attribute attr = as.get(id);
                for (int i = 0; i < attr.size(); ++i) {
                    out.println(id + ": " + attr.get(i));
                }
            }
        }
        ctx.close();

        out.flush();
    } catch (Exception e) {
        throw new ServletException(e);
    }
}
 
Example 15
Source File: MailValidation.java    From hop with Apache License 2.0 5 votes vote down vote up
private static ArrayList<String> getMX( String hostName ) throws NamingException {
  // Perform a DNS lookup for MX records in the domain
  Hashtable<String, String> env = new Hashtable<String, String>();
  env.put( "java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory" );
  DirContext ictx = new InitialDirContext( env );
  Attributes attrs = ictx.getAttributes( hostName, new String[] { "MX" } );
  Attribute attr = attrs.get( "MX" );

  // if we don't have an MX record, try the machine itself
  if ( ( attr == null ) || ( attr.size() == 0 ) ) {
    attrs = ictx.getAttributes( hostName, new String[] { "A" } );
    attr = attrs.get( "A" );
    if ( attr == null ) {
      throw new NamingException( BaseMessages.getString( PKG, "MailValidator.NoMatchName", hostName ) );
    }
  }

  // Huzzah! we have machines to try. Return them as an array list
  // NOTE: We SHOULD take the preference into account to be absolutely
  // correct. This is left as an exercise for anyone who cares.
  ArrayList<String> res = new ArrayList<String>();
  NamingEnumeration<?> en = attr.getAll();

  while ( en.hasMore() ) {
    String x = (String) en.next();
    String[] f = x.split( " " );
    if ( f[ 1 ].endsWith( "." ) ) {
      f[ 1 ] = f[ 1 ].substring( 0, ( f[ 1 ].length() - 1 ) );
    }
    res.add( f[ 1 ] );
  }
  return res;
}
 
Example 16
Source File: MailValidation.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * verify if there is a mail server registered to the domain name. and return the email servers count
 */
public static int mailServersCount( String hostName ) throws NamingException {
  Hashtable<String, String> env = new Hashtable<String, String>();
  env.put( "java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory" );
  DirContext ictx = new InitialDirContext( env );
  Attributes attrs = ictx.getAttributes( hostName, new String[] { "MX" } );
  Attribute attr = attrs.get( "MX" );
  if ( attr == null ) {
    return ( 0 );
  }
  return ( attr.size() );
}
 
Example 17
Source File: DirContextURLConnection.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
/**
 * Returns an unmodifiable Map of the header fields.
 */
@Override
public Map<String,List<String>> getHeaderFields() {

  if (!connected) {
      // Try to connect (silently)
      try {
          connect();
      } catch (IOException e) {
          //Ignore
      }
  }

  if (attributes == null)
      return (Collections.emptyMap());

  HashMap<String,List<String>> headerFields =
      new HashMap<String,List<String>>(attributes.size());
  NamingEnumeration<String> attributeEnum = attributes.getIDs();
  try {
      while (attributeEnum.hasMore()) {
          String attributeID = attributeEnum.next();
          Attribute attribute = attributes.get(attributeID);
          if (attribute == null) continue;
          ArrayList<String> attributeValueList =
              new ArrayList<String>(attribute.size());
          NamingEnumeration<?> attributeValues = attribute.getAll();
          while (attributeValues.hasMore()) {
              Object attrValue = attributeValues.next();
              attributeValueList.add(getHeaderValueAsString(attrValue));
          }
          attributeValueList.trimToSize(); // should be a no-op if attribute.size() didn't lie
          headerFields.put(attributeID, Collections.unmodifiableList(attributeValueList));
      }
  } catch (NamingException ne) {
        // Shouldn't happen
  }

  return Collections.unmodifiableMap(headerFields);

}
 
Example 18
Source File: LdapRolesMappingProvider.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected void rolesSearch(InitialLdapContext ctx, SearchControls constraints, String user, String previousRoleDn,
                           int recursionMax, int nesting, RoleGroup roleGroup) throws NamingException
{
   Object[] filterArgs = {user};
   String searchFilter = previousRoleDn == null ? roleFilter : "member=" + previousRoleDn;
   NamingEnumeration<SearchResult> results = ctx.search(rolesCtxDN, searchFilter, filterArgs, constraints);
   try
   {
      while (results.hasMore())
      {
         SearchResult sr = results.next();
         String dn = canonicalize(sr.getName());

         // Query the context for the roleDN values
         String[] attrNames = {roleAttributeID};
         Attributes result = ctx.getAttributes(dn, attrNames);
         if (result != null && result.size() > 0)
         {
            Attribute roles = result.get(roleAttributeID);
            for (int n = 0; n < roles.size(); n++)
            {
               String roleName = (String) roles.get(n);
               if (roleAttributeIsDN && parseRoleNameFromDN)
               {
                  parseRole(roleName, roleGroup);
               }
               else if (roleAttributeIsDN)
               {
                  // Query the roleDN location for the value of roleNameAttributeID
                  String roleDN = roleName;
                  String[] returnAttribute = {roleNameAttributeID};
                  PicketBoxLogger.LOGGER.traceFollowRoleDN(roleDN);
                  try
                  {
                     Attributes result2 = ctx.getAttributes(roleDN, returnAttribute);
                     Attribute roles2 = result2.get(roleNameAttributeID);
                     if (roles2 != null)
                     {
                        for (int m = 0; m < roles2.size(); m++)
                        {
                           roleName = (String) roles2.get(m);
                           addRole(roleName, roleGroup);
                        }
                     }
                  }
                  catch (NamingException e)
                  {
                     PicketBoxLogger.LOGGER.debugFailureToQueryLDAPAttribute(roleNameAttributeID, roleDN, e);
                  }
               }
               else
               {
                  // The role attribute value is the role name
                  addRole(roleName, roleGroup);
               }
            }
         }

         if (nesting < recursionMax)
         {
            rolesSearch(ctx, constraints, user, dn, recursionMax, nesting + 1, roleGroup);
         }
      }
   }
   finally
   {
      if (results != null)
         results.close();
   }
}
 
Example 19
Source File: DefaultObjectDirectoryMapper.java    From spring-ldap with Apache License 2.0 4 votes vote down vote up
@Override
public void mapToLdapDataEntry(Object entry, LdapDataEntry context) {
    ObjectMetaData metaData=getEntityData(entry.getClass()).metaData;

    Attribute objectclassAttribute = context.getAttributes().get(OBJECT_CLASS_ATTRIBUTE);
    if(objectclassAttribute == null || objectclassAttribute.size() == 0) {
        // Object classes are set from the metadata obtained from the @Entity annotation,
        // but only if this is a new entry.
        int numOcs=metaData.getObjectClasses().size();
        CaseIgnoreString[] metaDataObjectClasses=metaData.getObjectClasses().toArray(new CaseIgnoreString[numOcs]);

        String[] stringOcs=new String[numOcs];
        for (int ocIndex=0; ocIndex<numOcs; ocIndex++) {
            stringOcs[ocIndex]=metaDataObjectClasses[ocIndex].toString();
        }

        context.setAttributeValues(OBJECT_CLASS_ATTRIBUTE, stringOcs);
    }

    // Loop through each of the fields in the object to write to LDAP
    for (Field field : metaData) {
        // Grab the meta data for the current field
        AttributeMetaData attributeInfo = metaData.getAttribute(field);
        // We dealt with the object class field about, and the DN is set by the call to write the object to LDAP
        if (!attributeInfo.isTransient() && !attributeInfo.isId() && !(attributeInfo.isObjectClass()) && !(attributeInfo.isReadOnly())) {
            try {
                // If this is a "binary" object the JNDI expects a byte[] otherwise a String
                Class<?> targetClass = attributeInfo.getJndiClass();
                // Multi valued?
                if (!attributeInfo.isCollection()) {
                    populateSingleValueAttribute(entry, context, field, attributeInfo, targetClass);

                } else {
                    // Multi-valued
                    populateMultiValueAttribute(entry, context, field, attributeInfo, targetClass);

                }
            } catch (IllegalAccessException e) {
                throw new InvalidEntryException(String.format("Can't set attribute %1$s", attributeInfo.getName()),
                        e);
            }
        }
    }
}
 
Example 20
Source File: BurpExtender.java    From Berserko with GNU Affero General Public License v3.0 4 votes vote down vote up
private void kdcAuto() {
	if (domainDnsName.isEmpty()) {
		JOptionPane.showMessageDialog(null,
				"Have to set the domain DNS name first", "Failure",
				JOptionPane.ERROR_MESSAGE);
		return;
	}

	List<String> results = new ArrayList<String>();
	try {
		Hashtable<String, String> envProps = new Hashtable<String, String>();
		envProps.put(Context.INITIAL_CONTEXT_FACTORY,
				"com.sun.jndi.dns.DnsContextFactory");
		DirContext dnsContext = new InitialDirContext(envProps);
		Attributes dnsEntries = dnsContext.getAttributes("_kerberos._tcp."
				+ domainDnsName.toLowerCase(), new String[] { "SRV" });
		if (dnsEntries != null) {
			Attribute attr = dnsEntries.get("SRV");

			if (attr != null) {
				for (int i = 0; i < attr.size(); i++) {
					String s = (String) attr.get(i);
					String[] parts = s.split(" ");
					String namePart = parts[parts.length - 1];
					if (namePart.endsWith(".")) {
						namePart = namePart.substring(0,
								namePart.length() - 1);
					}
					results.add(namePart);
				}
			}
		}
	} catch (Exception e) {
		if (e.getMessage().startsWith("DNS name not found")) {
			JOptionPane
					.showMessageDialog(
							null,
							"Couldn't find any suitable DNS SRV records - is (one of) your DNS server(s) in the domain?",
							"Failure", JOptionPane.ERROR_MESSAGE);
		} else {
			JOptionPane.showMessageDialog(null,
					"Failure doing DNS SRV lookup", "Failure",
					JOptionPane.ERROR_MESSAGE);
			log(1,
					"Unexpected error when doing DNS SRV lookup: "
							+ e.getMessage());
			logException(2, e);
		}
		return;
	}

	if (results.size() == 0) {
		JOptionPane.showMessageDialog(null, "No DNS entries for KDC found",
				"Failure", JOptionPane.ERROR_MESSAGE);
		return;
	}

	String selectedValue = "";

	if (results.size() == 1) {
		selectedValue = results.get(0);
	} else {
		Object[] possibilities = new Object[results.size()];
		for (int ii = 0; ii < results.size(); ii++) {
			possibilities[ii] = results.get(ii);
		}
		selectedValue = (String) JOptionPane.showInputDialog(null,
				"Multiple KDCs were found", "Select KDC",
				JOptionPane.PLAIN_MESSAGE, null, possibilities,
				results.get(0));
	}

	if (!selectedValue.isEmpty()) {
		kdcHost = selectedValue;
		kdcTextField.setText(selectedValue);
		domainStatusTextField.setText("");

		setDomainAndKdc(domainDnsName, kdcHost);
	}
}