I found this chunk of code online somewhere and I am trying to get it to work in our companies environment. All I am trying to do is create AD groups from a Java application. The problem is that the code wants an LDAP URL. We have an alias that we use to access our LDAP environment that is in the format of "ldap.mycompany.com". I tried using the alias, but I get an error because its not in a URL format. Any ideas on how to fix this? I also noticed that Hashtable is detracted. What would be a good replacement for this? Hashmap? Thanks.

Java Code:
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttributes;
import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapContext;
import javax.swing.JOptionPane;

public class CreateGroup {

    public int adgroup(String groupname, String description) {
        int error =0;
        Hashtable env = new Hashtable();

        String adminName = "CN=myname,OU=Users,OU=Accounts,DC=cs,DC=mycompany,DC=net";
        String adminPassword = "xxxxxx";
        String ldapURL = "ldap.mycompany.com:389";
        String group = groupname + ",OU=Tool_Access,OU=Application_Groups,DC=gs,DC=mycompany,DC=net";
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");

        //set security credentials, note using simple cleartext authentication
        env.put(Context.SECURITY_AUTHENTICATION, "simple");
        env.put(Context.SECURITY_PRINCIPAL, adminName);
        //env.put(Context.SECURITY_CREDENTIALS, adminPassword);

        //connect to my domain controller
        env.put(Context.PROVIDER_URL, ldapURL);

        try {
            // Create the initial directory context
            LdapContext ctx = new InitialLdapContext(env, null);

            // Create attributes to be associated with the new group 
            Attributes attrs = new BasicAttributes(true);
            attrs.put("objectClass", "group");
            attrs.put("samAccountName", groupname);
            attrs.put("cn", groupname);
            attrs.put("description", description);

            //group types
            int ADS_GROUP_TYPE_GLOBAL_GROUP = 0x0002;
            int ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP = 0x0004;
            int ADS_GROUP_TYPE_LOCAL_GROUP = 0x0004;
            int ADS_GROUP_TYPE_UNIVERSAL_GROUP = 0x0008;
            int ADS_GROUP_TYPE_SECURITY_ENABLED = 0x80000000;

            attrs.put("groupType", Integer.toString(ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP + ADS_GROUP_TYPE_SECURITY_ENABLED));

            // Create the context
            Context result = ctx.createSubcontext(group, attrs);
            System.out.println("Created group: " + group);


        } catch (NamingException ex) {
                    "Could not create Active Directory group:" + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
            error =1;
      return error;