Tuesday, March 29, 2011

Malformed container error in IMail server

Ah... symantec decided to start marking random emails sent through ipswitch as virus...and i was alarmed..

This was the solution on IPSwitch site

This happens when something in the message did not conform to one of the RFC's for MIME Encoding. These RFC's are 2045-2049. This is usually caused by a mail client that is improperly formatting the message. There are two options to remedy the issue. You can disable the "Malformed Container Processing" or determine a way to compose the message in a way that formats the message properly. This may mean using a different client or contacting the mail client vendor.
To disable Malformed Container Processing, follow the steps below:
1.) On the server, open https://localhost:8004  in a browser.
2.) Log in with the password created during installation, otherwise click in the password field and press the enter key.
3.) Click on the "Policies" icon on the left.
4.) Click "Filtering" located in the margin.
5.) Click on the "Container Handling" tab.
6.) In the "Malformed Container File Processing" section, uncheck the "Block malformed containers."
7.) Click Apply icon, (brown arrow, second icon in upper left corner).

But the world is not that eazy... the JRE refused to run the applet needed for antivirus interfacel...
load: class com.symantec.gui.guidelines.ScanEngineApplet not found.
java.lang.ClassNotFoundException: com.symantec.gui.guidelines.ScanEngineApplet
        at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
        at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
        at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:https://:8004/com/symantec/gui/guidelines/ScanEngineApplet.class
        at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
        at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
        at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        ... 7 more
Exception: java.lang.ClassNotFoundException: com.symantec.gui.guidelines.ScanEngineApplet
I went to Symentec site and looked around
They said the following
The problem is on client side.  
Remove 1.6.0_12 Jre.  It can only run with 1.5.0 JRE. 
If you have both 1.6 and 1.5 installed, then browser will use 1.6 causing you problem.
I had the same issue but solved.  Symantec has the solution listed here.
http://service1.symantec.com/support/ent-gate.nsf/docid/2008092215494254

So, I went to Java site next and they said to do the following to remove "older versions"

Windows 7 and Vista - Uninstall Programs
  1. Click Start
  2. Select Control Panel
  3. Select Programs
  4. Click Programs and Features
  5. Select the program you want to uninstall by clicking on it, and then click the Uninstall button.
You may need administrator privileges to remove programs.
Windows XP - Uninstall Programs
  1. Click Start
  2. Select Control Panel
  3. Click the Add/Remove Programs control panel icon
  4. The Add/Remove control panel displays a list of software on your system, including any Java software products that are on your computer. Select any that you want to uninstall by clicking on it, and then click the Remove button.
Am just a lowly sys admin not about to challenge the mighty java folk...So, I did as they commanded and removed JRE 1.6.0_12 from my machine and VOILA... I was able to follow the IPswitch's initial instructions to the word... 

Ah sometimes you really do have to step back to step forward....

Monday, March 28, 2011

Viewstates in C#

So, as is inevitable with any .NET admin.. (pseudo admin in my case)... I ran headfirst into a fight with the viewstates...

Between the various view state errors... I looked online and found this


 What does the EnableViewStateMac setting in an aspx page do?
Setting EnableViewStateMac=true is a security measure that allows ASP.NET to ensure that the viewstate for a page has not been tampered with. If on Postback, the ASP.NET framework detects that there has been a change in the value of viewstate that was sent to the browser, it raises an error - Validation of viewstate MAC failed.
Use <%@ Page EnableViewStateMac="true"%> to set it to true (the default value, if this attribute is not specified is also true) in an aspx page.

I also highly recommend reading this article


It is very precise explanation of the devil that is viewstate

Wednesday, March 23, 2011

Comparing dates in C#


DateTime date1 = new DateTime(2009, 8, 1, 0, 0, 0);
DateTime date2 = new DateTime(2009, 8, 1, 12, 0, 0);
int result = DateTime.Compare(date1, date2);
string relationship;

if (result < 0)
   relationship = "is earlier than";
else if (result == 0)
   relationship = "is the same time as";         
else
   relationship = "is later than";

Response.Write(string.format("{0} {1} {2}", date1, relationship, date2));


 The example displays the following output:
//    8/1/2009 12:00:00 AM is earlier than 8/1/2009 12:00:00 PM

Tuesday, March 22, 2011

Session ticker with Javascript and C#

So, I built the awesomest application in the world and was stumped by a simple conundrum..

The users didnt realize they were getting timed out

So I found this gem... and modified it to be added to the master page


  var sessionTimeout = "<%= Session.Timeout %>";
  
        function DisplaySessionTimeout()
        {

            var sessionValue = '<%= Session["userID"] %>';
            //assigning minutes left to session timeout to Label
            if ((sessionValue != "")&&(sessionTimeout > 0)) {

                document.getElementById("<%= lblSessionTime.ClientID %>").innerText =
                                                                       "Session time left: " + sessionTimeout + " minutes";
                sessionTimeout = sessionTimeout - 1;

                //if session is not less than 0

                //call the function again after 1 minute delay
                window.setTimeout("DisplaySessionTimeout()", 60000);
            }
//            else {
//                //show message box
//                alert("Your current Session is over.");
//            }
        }




after adding this to the head.. I added this label to the body

    
        < asp: Label ID ="lblSessionTime" CssClass="showGreen" runat="server" >

and VOILA !! there is a green ticker updating every min informing people of the impending doom.. I mean session timeout

AH HAAA