ArtinSoft's Blogs

Software Migration Experts
Welcome to ArtinSoft's Blogs Sign in | Join | Help
in Search

Mauricio Rojas Blog

May 2007 - Posts

  • Localize your VB apps

    Localize a VB6 application can be cumbersome, specially if it was not even originally planned to be localized.
    Nowadays is common that you're clients might demand support for different languages.
    While a localization task is still difficult, we have found excellent results performing it during a VB Migration.
    Our tools allow us to easily externalize all your strings. After that the traslation task becomes easy, and you can even use the help
    of nice projets like Automatically Translate your .NET resource files with Google Translate

  • Active Directory, Password Expired

    There are a list of situations you might want to handle with Active Directory:

    525 - user not found
    52e - invalid credentials
    530 - not permitted to logon at this time
    532 - password expired
    533 - account disabled
    701 - account expired
    773 - user must reset password

     
    This is an extract of the Java Forum to handle these cases. Good Luck!
     
    } catch (AuthenticationException e) {
    String tempString;
    StringTokenizer tokenizerTemp = new StringTokenizer(e.toString());
    while (tokenizerTemp.hasMoreElements()) {
             tempString = tokenizerTemp.nextToken();
             if (tempString.equalsIgnoreCase("AcceptSecurityContext")) {
                     while (tokenizerTemp.hasMoreElements()) {
                              tempString = tokenizerTemp.nextToken();
                              if (tempString.startsWith("773"))
                                       setIsPasswordExpired(true);
                              if (tempString.startsWith("52e"))
                                       setIsPasswordWrong(true);
                              if (tempString.startsWith("533"))
                                       setIsAccountDisabled(true);
                     }
             }
    }
    throw new NamingException();
    }

     

     

    Posted May 14 2007, 01:46 PM by Mrojas with no comments
    Filed under:
  • Active Directory LDAP and Java

    It is common that after a migration to Java, specially coming from legacy platforms like LINC or COBOL, that our clients want to take advantage of new technologies. So it happens that they are now authenticating against an Active Directory or another LDAP server. And thanks to the new platforms it is really easy for us to help them integrate this new functionality.
    This is sample program that show how to authenticate with for example a Windows Active Directory.

    import java.io.BufferedReader;
    import
    java.io.InputStreamReader;
    import
    java.util.Hashtable;

    import javax.naming.Context;
    import
    javax.naming.NamingEnumeration;
    import
    javax.naming.NamingException;
    import
    javax.naming.directory.Attributes;
    import
    javax.naming.directory.SearchControls;
    import
    javax.naming.directory.SearchResult;
    import
    javax.naming.ldap.InitialLdapContext;
    import
    javax.naming.ldap.LdapContext;

    public class LDAPTest
    {
           static class LDAP
         
    {
                static String ATTRIBUTE_FOR_USER = "sAMAccountName";
                public Attributes authenticateUser(String username, String password, String _domain, String host, String dn)
                {

                      String returnedAtts[] ={ "sn", "givenName", "mail" };
                      String searchFilter = "(&(objectClass=user)(" + ATTRIBUTE_FOR_USER + "=" + username + "))";
                      //Create the search controls

                      SearchControls searchCtls = new SearchControls();
                      searchCtls.setReturningAttributes(returnedAtts);
                      //Specify the search scope

                      searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
                      String searchBase = dn;
                      Hashtable environment = new Hashtable();
                      environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
                      //Using starndard Port, check your instalation

                      environment.put(Context.PROVIDER_URL, "ldap://" + host + ":389");
                      environment.put(Context.SECURITY_AUTHENTICATION, "simple");

                      environment.put(Context.SECURITY_PRINCIPAL, username + "@" + _domain);
                      environment.put(Context.SECURITY_CREDENTIALS, password);
                      LdapContext ctxGC = null;
                      try
                     
    {
                            ctxGC = new InitialLdapContext(environment, null);
                            //    Search for objects in the GC using the filter

                            NamingEnumeration answer = ctxGC.search(searchBase, searchFilter, searchCtls);
                            while (answer.hasMoreElements())
                            {
                                  SearchResult sr = (SearchResult)answer.next();
                                  Attributes attrs = sr.getAttributes();
                                  if (attrs != null)
                                  {
                                        return attrs;
                                  }
                            }

                       }
                      catch (NamingException e)
                     
    {
                            System.out.println("Just reporting error");
                           
    e.printStackTrace();
                      }
                      return null;
                }
         }

          public static void main(String[] args) throws Exception
         
    {
                InputStreamReader converter = new InputStreamReader(System.in);
                BufferedReader in = new BufferedReader(converter);
                System.out.println("Please type username:");
                String username = in.readLine();
                System.out.println("Please type password:");
                String password = in.readLine();
                LDAP ldap = new LDAP();

                //Yo specify in the authenticate user the attributes that you want returned

                //Some companies use standard attributes like 'description' to hold an employee ID

                //The ActiveDirectory data can be enhanced to add custom attributes like

                //printer

                // Some instalations usually have several ACtiveDirectoryServers, lets say

                // 192.150.0.8, 192.150.0.7 y 192.150.0.9 and they use a

                // DNS round robin to balance the load

                Attributes att = ldap.authenticateUser(username, password, "mydomain.com", "myactivedirectoryhost.com", "DC=mydomain,DC=com");
                if (att == null)
                {
                      System.out.println("Sorry your use is invalid or password incorrect");
                }
                else
               
    {
                      String s = att.get("givenName").toString();
                      System.out.println("GIVEN NAME=" + s);
                }
          }
    }

     


    Posted May 14 2007, 01:29 PM by Mrojas with no comments
    Filed under:
  • DoEvents?? in .NET

    This is small Example. I had a POS Application in VB6 with this code. Me.EpsonFPHostControl1.SendCommand While EpsonFPHostControl1.State = EFP_S_Busy DoEvents Wend This code is almost the same in VB.NET Me.AxEpsonFPHostControl1.SendCommand() While AxEpsonFPHostControl1.CtlState = EpsonFPHostControlX.TxFiscalState.EFP_S_Busy Application.DoEvents() End While
  • Migration of VB6 POS

    POS (Point of Sale) software is everywhere. Whether you're at a Bar, at Denny's, Pizza Hut, BK or at the Duty Free. It is maybe one of the software's more commonly used. A POS system is generally simple. It manages a basic inventory, registers sales, and somethings manages credit card payments. Obviously there are far more complex POS systems. A lot of POS systems where programmed in VB6. But as you know VB6 language (and I'm not discussing the reasons here) is now a dead language. A lot of customers do not want to buy VB6 applications, even if they get the job done. So it's time to move on. This is the First of a series of posts around issues migrating VB6 POS applications. If you have any comments just send them now!
  • Events not firing in ToolPart

    I was developing a WebPart and I came up with a situation where my custom ToolPart did not fired the events. I found this post that solved the problem. " I moved the databinding code into the CreateChildControls() code: protected override void CreateChildControls() { dllCatagory = new DropDownList(); dllCatagory.Visible = true; dllCatagory.AutoPostBack = true; dllCatagory.Attributes.Add("runat", "server"); dllCatagory.SelectedIndexChanged += new EventHandler(dllCatagory_SelectedIndexChanged); CdCatagoryList.CatagoryList cdCatL; cdCatL = new CdCatagoryList.CatagoryList(); //cdCat.Catlist is a dll that will get the data. DataView tviewFolders = cdCatL.CatList(true, "cdadmin", "", "server=192.168.221.246;uid=DataSa;pwd=pa456;database=ContentDepot"); dllCatagory.DataSource = tviewFolders; dllCatagory.DataValueField = "FolderNumber"; dllCatagory.DataTextField = "FolderName"; dllCatagory.DataBind(); Controls.Add(dllCatagory); } public void dllCatagory_SelectedIndexChanged(object sender, EventArgs e) { //Code to load the gridview //This event now fires} protected override void RenderToolPart(HtmlTextWriter output) { EnsureChildControls(); dllCatagory.RenderControl(output); } "
Powered by Community Server (Non-Commercial Edition), by Telligent Systems