samirpat

Name:
Location: Mumbai, India

Tuesday, June 24, 2008

Ladakh Trip Log

Hello Everyone,
All of you are eagerly waiting for the trip log of our trip to Ladakh on our bikes, i know but due to assignments in the office it was very difficult to take out time and complete this. I really apologise for the delay.
So here it goes.............................................................
A littel bit of our Background.
We are members of a biking club of mumbai in Indai which we proudly call as "Mumbai Bikers Club" or MBC. we are bike freaks we love our bike more then our girl friends sorry honey if you are reading this. but yes it is a fact. Ladak trip is the longest ride we had from this group and OM one of the Key member is leaving for the same in a couple of days. it all started about 6 months back first we were planning for Himalayan ride towards char dham most of you will knowing about that, but later we changed it to Ladak.
Initially there were many riders who gave were willing to join us for the ride but coulnt make it for various reasons, and finally Four of us were confirmed for the ride, that tooo with lot of hichups anna listening na hehehe.
The final four riders:
  • Gaurav Thakkar(Avenger 2yrs old).
  • Venugopal aka Maverick (Pulsar 200 approx 9 months old).
  • Nitin Shetty aka Anna.com (Apache RTR 9 month).
  • Samir (Apache RTR 9 months).

the trip was schedule to start from 16th May 2008. in the evening from Sidhi Vinayak Temple in dadar. but my bike's chain broke the very same day and had to fix it so couldnt make it there.

Gaurav and Mavei started from the temple, Kamal and simi from Bombay bikers were there to c them off thanks to you buddy. me and anna caught up with them at borivali highway ashish was also with us to c us off hehehe sorry ashu but loved ur face when we were leaving .

Day 1:

We started from borivali at about 11.30 pm on 16th may iwas a bit tensed about the night driving cause of such a long distance and with new riders. we started off well and were cruising at 50-60kmph initailly till dhanu just not to get over exited for the ride. crossed the toll naka near dhanu when our first tragedy struck us, annas rear tyre got flat hmmmmm not expected to happen after riding just for 2 hrs.

so found a punchure wala and got it fixed it costed us about 2 hrs there. began riding and rode for whole night at speed of 70-80kmph the target for us was to reach ahemedabad. by 6 in the moring we reached surat, the road between surat and baroda are pathetic at surat took a break for tea and sutta mavi was the only person who had been smoking the entire trip. sala abhi tho mein tb se bahar aaya hun wapas daal dega mere ko dhuaa chod chod ke. now were not aware of a typical but interesting habbit of anna, he generally is awake the whole night and killing his time on orkut and sleeps the whole day like a pig. so since it was morning now his rings started ringing, and started feeling sleepy. at about 9 am tragedy struck again n that too with anna. he just dozed off on the bike and had a fall on the side of the road and it was a amazing fall no one can beet his record. anna bolu kya kidhar gira? guess any one? well our anna slipped on the side of the road his bike went down the side of the road and our anna goes down in the manhole, yes u read it correct anna went down in the manhole which was being constructed, and he hit it so hard that the concrete broke off on the top and this guy was inside upside down now u can imagine how he might have been worth watching hehehe.


Thursday, June 08, 2006

Using Cache In Win Form Applications

Caching the objects is possible directly in the ASP.Net Applications as the cache component is a part of the .Net Framework Specifically used for caching the web pages and other objects on the net.

This can also be used in the Normal WinForm applications so that u can reduce the over heads of creating the objects again and again from the Scratch.

For this u need to give the reference to System.Web.Caching assembly.

Code Sample:
using System.Web;
using System.Web.Caching;


//in the class defination.
private static HttpRuntime _httpRuntime;
private const string CACHE_KEY = "CACHEKEY";

public static Cache Cache
{
get
{
EnsureHttpRuntime();
return HttpRuntime.Cache;
}
}
private static void EnsureHttpRuntime()
{
if( null == _httpRuntime )
{
try
{
Monitor.Enter( typeof( clsConn ) );
if( null == _httpRuntime )
{
// Create an Http Content to give us access to the cache.
_httpRuntime = new HttpRuntime();
}
}
finally
{
Monitor.Exit( typeof( clsConn ) );
}
}
}

//then to access the cached object.
public OracleConnection OrclConnection()
{
OracleConnection pConn;
pConn = clsConn.Cache[CACHE_KEY] as OracleConnection;
if( null == pConn )
{
pConn=new OracleConnection(pConnectString);
clsConn.Cache.Insert(
CACHE_KEY,
pConn,
null,
Cache.NoAbsoluteExpiration,
TimeSpan.FromSeconds(3600));
}
try
{
if(pConn.State==0){pConn.Open();}
return pConn;
}
catch(Exception e)
{
return pConn;
}
}

Friday, May 19, 2006

Crystal Reports Not Showing Images On Net

Have u ever wondered y ur crystal reports in asp.net application which displays images properly in developer computer and not on the Production Web Server.

The reason being though u install the web application through the set up wizards by installing the Keycode License there is one particular setting that is not being done by the installer it has to be done manually.

This is the registry entries that u have to do.

this entry is in
"HKEY_LOCAL_MACHINE"
"SYSTEM"
"CURRENTCONTROLSET"
"SERVICES"
"W3SVC"
"PARAMETERS"
"VIRTUAL ROOTS"

Actually whenever Crystal reports uses images in the Reports they are created in a particular folder which is then mpped as a virtual directory on the IIS. it then references this folder as a URL.

there are two keys that are needed in this Keys.

1.) "/Crystal_license" = C:\Program Files\Seagate Software\Shared\Design Time Control\ASP,,1 this is the asp pages that are used by crystal reports.

2.) "/CrystalReportWebFormViewer" = C:\Program Files\Microsoft Visual Studio .NET\Crystal Reports\Viewers\,,201
this is the reference to the actual component which renders the images at runtime.


Happy Coding.
:-)

System.Runtime.Reflection

Here's a way to access the Objects that are added to ur current form without actually going through loop of the control list.

Normally one will loop through the Controls Collection and look for a particular control this is very efficient if you have very less no of controls, imagine a form having many controls and you need to change the properties of the controls dynamically doing this by looping will slow down the application.

The other way is to use Hashtable instead, HashTable is nothing but a collection of the References of the objects.
Example:
C#
using System.Collection;
using System.Refelection;

HashTable tmpHashTable=new Hashtable();
private void InitializaComponent()
{
//Here add all the controls to the HashTable.
tmpHashTable.Add(Control.Name, Control);
}

Then u can directly refere to the Object i.e get the reference of a particular object by just passing the name of the control.

Control tmpControl=(Control)tmpHashTable[Name of the Control];

Note: Hash Table Contains Only Reference of the Object and not the actual object.
so to use the properties u have to type cast the object to control.

Wednesday, August 24, 2005

Configuring DCOM MSMQ For J-Integra

Configuring DCOM for MSMQ and J-Integra


Before you can run any J-Integra application, you must ensure that DCOM is
properly configured. Failure to do so typically results in one of the following
errors:


  • AutomationException: 0x80070005 - General access denied error
  • AutomationException: 0x5 - access is denied
  • Run-time error '70': Permission denied


DCOM Authentication


Before you can access a COM component via DCOM, you must provide the
authentication credentials of a user who has been granted permission to
access/launch the component. There are two ways to do this.



  1. Native Authentication

  2. By default, J-Integra will use native code to determine the user
    credentials of the user who is currently logged in. This will only work if the
    following conditions are met:



    • The Java client resides on a Windows machine. If the Java client is
      located on a non-Windows machine, you must use AuthInfo.setDefault()
      to provide authentication credentials (see below).
    • The %JINTEGRA_HOME%\bin directory must be in the system
      PATH, and ntvauth.dll must reside there. This DLL contains the
      native code J-Integra uses to determine the local authentication
      credentials.
    • If the Java client is running on machine A, then the credentials of the
      user who is currently logged on to machine A must be configured on machine B
      to have access/launch permissions to the COM component being accessed. For
      more information on DCOM Configuration, see below.



  3. AuthInfo.setDefault

  4. If you are running on a non-Windows platform, or you wish to use the
    credentials of someone other than the user who is currently logged in, then
    you need to use the method AuthInfo.setDefault().
    This identitiy will be used on a process-wide basis when accessing and using
    COM components.To use this method, place the following line in your Java
    client before any calls to the COM component:


      com.linar.jintegra.AuthInfo.setDefault("DOMAIN", "USER",
      "PASSWORD");

      * Using AuthInfo.setDefault() will only work if the Windows
      machine hosting the COM component belongs to a domain or is a domain
      controller.

      DOMAIN - The domain to which the user belongs. If the user
      does not belong to a domain, then pass the name of the machine to which the
      user belongs. Note that COMPUTER\USER and DOMAIN\USER are two
      completely different security principles. For more information, please refer
      to Microsoft's http://support.microsoft.com/default.aspx?scid=kb;en-us;158508"USER - The username
      being used to access the COM component.
      PASSWORD - The
      password of the above username.


    You may override the process-wide default using AuthInfo.setThreadDefault().
    This method establishes the authentication to be used for the current
    thread
    only. To clear the authentication for the current thread, call
    AuthInfo.setThreadDefault(null). Please note that
    setThreadDefault() will behave differently if the COM component
    is a "single instance" component. For more information, see AuthInfo.setThreadDefault(...) and Single-Instance COM
    Objects
    in the Knowledge Base.

    Regardless of whether or not you set the authentication on a per-thread
    basis, it is strongly recommended that you call
    AuthInfo.setDefault() early in your Java code to establish the
    authentication to be used on a process-wide basis. This is needed to allow
    J-Integra daemon threads to perform authenticated communications (such as when
    releasing COM object references that have been garbage collected).

    name=non-ansi>


  5. DCOM Authentication for Usernames with Non-ANSI Characters

  6. Because Java supports non-ANSI characters, you can use
    domain/username/password combinations with non-English characters. In order to
    use non-English characters, you need to make sure that the same non-English
    language is set as the default language on both the computer running the Java
    client and the computer hosting the COM component.

    Follow the steps below to configure the Windows 2000/XP English version
    machine hosting the COM component:


    1. Click Start, click Control Panel, click Regional and
      Language Options
      .
    2. Click Advanced, select your language in Code page conversion
      tables
      , and select your language from the Language for non-Unicode
      programs
      dropdown combo box. This will set the new default language and
      allow non-English characters.
    3. Click OK button. Then reboot the machine for the settings to take
      effect.
    4. href="http://j-integra.intrinsyc.com/support/com/doc/remoteaccess.html#Config">Configure
      DCOM
      to grant DCOM access/launch permissions to the non-English
      username.

    Follow the steps below to configure the Windows NT English version machine
    hosting the COM component:


    1. Click Start, click Control Panel, click Regional
      Settings
      .
    2. Click Reginal Settings tab, select your language in from the
      Many programs support international settings... dropdown combo box,
      check Set as system default local checkbox. Click Input Locals
      tab, add your language to Installed input locals and layouts list
      box, select the language you just added, and click Set as Default
      button.
    3. Click the OK button. Then reboot the machine for the settings to
      take effect.
    4. href="http://j-integra.intrinsyc.com/support/com/doc/remoteaccess.html#Config">Configure
      DCOM
      to grant DCOM access/launch permissions to the non-English
      username.

    If your Java client machine is also Windows, follow steps 1-3 above to
    configure the machine. You can then pass non-English characters to
    com.linar.jintegra.AuthInfo.setDefault().

    Please refer to your platform manual to set the default language if your
    Java client machine is a non-Windows platform.





DCOM Configuration (DCOMCNFG)


DCOMCNFG is a tool that comes with Windows that allows users to configure the
DCOM settings of a COM application. J-Integra provides its own DCOM
configuration tool called href="http://j-integra.intrinsyc.com/support/com/doc/tools/dcomconfig.html">DCOMConfig.exe.
J-Integra's DCOMConfig tool is a simplified version of Window's DCOMCNFG meant
for users who are new to J-Integra and/or DCOM. If you'd rather use
DCOMConfig.exe, please refer to the href="http://j-integra.intrinsyc.com/support/com/doc/tools/dcomconfig.html">tool
description
.

We recommend the following DCOM configuration settings as a starting point if
you are unfamiliar with J-Integra and/or DCOM. Once you are more comfortable
with DCOM configuration, feel free to modify your settings based on your own set
of requirements.

* Configuring DCOM is mandatory when running J-Integra in href="http://j-integra.intrinsyc.com/support/com/doc/dcom_native.html">DCOM
mode
. However, if you are using href="http://j-integra.intrinsyc.com/support/com/doc/dcom_native.html">native
mode
, DCOM configuration is seldom necessary (since standard COM is used for
communication between components, not DCOM). However, if you are running in
native mode and you are still getting "access denied" errors, please configure
DCOM as instructed below.





Configuring DCOM on Windows 2000




  1. Click Start, click Run, and then type DCOMCNFG.


  2. Click Default Properties. Select Enable Distributed COM on this
    computer
    . Set the Default Authentication Level to Connect
    (None also works). Set the Default Impersonation Level to
    Identify (Impersonate also works).

    Here are the rules regarding Authentication Level for J-Integra
    applications:


    • The Authentication Level doesn't matter if you are running in native
      mode.
    • The machine hosting the COM client/server application must be set to
      Connect or None level authentication, as this is
      all that J-Integra supports. It doesn't matter what the Authentication Level
      is on the machine running J-Integra.
    • For COM-accessing-Java applications, the Authentication Level on the COM
      client machine must be set to Connect or None.
    • For Java-accessing-COM applications, the Authentication Level on the COM
      server machine must be set to Connect or None.


  3. Click Default Security.


  4. Under Default Access Permissions click Edit Default. Add
    SYSTEM and INTERACTIVE. The user whose authentication
    credentials will be used to access the COM application must also be included
    in this list. There are many ways to do this. You can add the specific user or
    simply add a group the user belongs to. Possible values include:



    • Domain\Username (A specific user)
    • Domain\Administrators (All administrators on a specific domain)
    • Everyone (All users)


  5. Under Default Launch Permissions click Edit Default. Make
    sure the Default Launch Permissions have the same values as the
    Default Access Permissions.


  6. Click Default Protocols. Make sure Connection-oriented
    TCP/IP
    is listed first.


  7. You must now configure the COM application you wish to access. Click
    Applications and right-click on the application you wish to configure.
    Select Properties. If your COM application is a DLL, you must first
    create a surrogate EXE for it using the href="http://j-integra.intrinsyc.com/support/com/doc/tools/SetDllHost.html">SetDllHost
    tool
    . Once a surrogate EXE is created, the surrogate name will appear in
    the list of applications. Select Properties for the surrogate and
    continue on.


  8. Click General. Set the Authentication Level to
    Default.


  9. Click Location. Select Run application on this computer.


  10. Click Security. Select Use default access permissions and
    Use default launch permissions.


  11. For Windows 2000 Workstation - Click Identity. Select The
    launching user
    . Depending on the COM application you are accessing, you
    may need to change this to The interactive user (e.g. if you are going
    to access MS Excel and make it visible).

    For Windows 2000 Terminal Server - Click Identity. Select
    The launching user. Depending on the COM application you are accessing,
    you may need to change this to The interactive user, otherwise you may
    get AutomationException: 0x8000401a - The server process could not be
    started because the configured identity is incorrect. Check the username and
    password
    . See the href="http://j-integra.intrinsyc.com/support/com/doc/remoteaccess.html#references">References
    section at the bottom of this page for more information on "configuring Office
    applications to run under the Interactive User Account with Terminal Servers".


  12. Click Endpoints. Select default system protocols.


  13. If you still get an "access denied" or "permission denied" error after
    configuring your DCOM settings, try rebooting your machine to allow the new
    settings to take effect.





Configuring DCOM on Windows XP and Windows Server 2003




  1. If the computer belongs to a workgroup instead of a domain, make sure that
    it does not use simple file sharing. Open Windows Explorer or double
    click My Computer, click Tools, then go to Folder
    Options
    , click View and uncheck Use simple file sharing
    (Recommended)
    in Advanced settings.


  2. Click Start, click Programs, click Administrative
    Tools
    , click Component Services.


  3. Expand Component Services, expand Computers, and right-click
    My Computer. Select Properties.


  4. Click Default Properties. Select Enable Distributed COM on this
    computer
    . Set the Default Authentication Level to Connect
    (None also works). Set the Default Impersonation Level to
    Identify (Impersonate also works).

    Here are the rules regarding Authentication Level for J-Integra
    applications:


    • The Authentication Level doesn't matter if you are running in native
      mode.
    • The machine hosting the COM client/server application must be set to
      Connect or None level authentication, as this is
      all that J-Integra supports. It doesn't matter what the Authentication Level
      is on the machine running J-Integra.
    • For COM-accessing-Java applications, the Authentication Level on the COM
      client machine must be set to Connect or None.
    • For Java-accessing-COM applications, the Authentication Level on the COM
      server machine must be set to Connect or None.


  5. Click Default COM Security.


  6. Under Default Access Permissions click Edit Default. Add
    SYSTEM, INTERACTIVE, and NETWORK. The user whose
    authentication credentials will be used to access the COM application must
    also be included in this list. There are many ways to do this. You can add the
    specific user or simply add a group the user belongs to. Possible values
    include:



    • Domain\Username (A specific user)
    • Domain\Administrators (All administrators on a specific domain)
    • Everyone (All users)


  7. Under Default Launch Permissions click Edit Default. Make
    sure the Default Launch Permissions have the same values as the
    Default Access Permissions.


  8. Click Default Protocols. Make sure Connection-oriented
    TCP/IP
    is listed first.


  9. You must now configure the COM application you wish to access. Expand
    Component Services, expand Computers, expand My Computer,
    and click DCOM Config. Right-click on the application you wish to
    configure. Select Properties. If your COM application is a DLL, you
    must first create a surrogate EXE for it using the href="http://j-integra.intrinsyc.com/support/com/doc/tools/SetDllHost.html">SetDllHost
    tool
    . Once a surrogate EXE is created, the surrogate name will appear in
    the list of applications. Select Properties for the surrogate and
    continue on.


  10. Click General. Set the Authentication Level to
    Default.


  11. Click Location. Select Run application on this computer.


  12. Click Security. Set Launch Permissions to Use
    Default
    . Set Access Permissions to Use Default. Set
    Configuration Permissions to Use Default.


  13. Click Identity. Select The launching user. Depending on the
    COM application you are accessing, you may need to change this to The
    interactive user
    (e.g. if you are going to access MSExcel and make it
    visible).


  14. Click Endpoints. Select default system protocols.


  15. If you still get an "access denied" or "permission denied" error after
    configuring your DCOM settings, try rebooting your machine to allow the new
    settings to take effect.





Configuring DCOM on Windows XP SP2


Microsoft has added some DCOM security enhancements to Windows XP Service
Pack 2. In addition to the href="http://j-integra.intrinsyc.com/support/com/doc/remoteaccess.html#winxp">above
Windows XP DCOM configuration settings, you will need to perform the following
steps.



  1. If the computer belongs to a workgroup instead of a domain, make sure that
    it does not use simple file sharing. Open Windows Explorer or double
    click My Computer, click Tools, then go to Folder
    Options
    , click View and uncheck Use simple file sharing
    (Recommended)
    in Advanced settings.


  2. Click Start, click Programs, click Administrative
    Tools
    , click Component Services.


  3. Expand Component Services, expand Computers, and right-click
    My Computer. Select Properties.


  4. Click Default COM Security.


  5. Under Default Access Permissions click Edit Default. Make
    sure SYSTEM, INTERACTIVE, NETWORK, and the user whose
    authentication credentials will be used to access the COM application all have
    Local and Remote Access permissions.


  6. Under Default Access Permissions click Edit Limits. Service
    Pack 2 comes with the following default values: ANONYMOUS LOGON (Local
    Access) and Everyone (Local and Remote Access). Make sure these values
    are listed, and then add the user whose authentication credentials will be
    used to access the COM application. Allow this user to have Local and
    Remote Access
    permissions.


  7. Under Default Launch Permissions click Edit Default. Make
    sure SYSTEM, INTERACTIVE, NETWORK, and the user whose
    authentication credentials will be used to access the COM application all have
    Local and Remote Launch permissions, as well as Local and Remote
    Activation
    permissions.


  8. Under Default Launch Permissions click Edit Limits. Service
    Pack 2 comes with the following default values: MACHINE\Administrators
    (Local and Remote Launch, Local and Remote Activation) and Everyone
    (Local Launch and Local Activation). Make sure these values are listed, and
    then add the user whose authentication credentials will be used to access the
    COM application. Allow this user to have Local and Remote Launch
    permissions, as well as Local and Remote Activation permissions.


  9. Service Pack 2 comes with a built-in Windows Firewall. If the firewall is
    turned on, you will have to allow your COM application network access to your
    machine. You can do this by opening Windows Firewall and adding your COM
    application to the list of programs under the Exceptions tab. If
    Display a notification when Windows Firewall blocks a program is
    selected, then you will be prompted to unblock the COM application when you
    run your J-Integra application the first time. Select Unblock when
    prompted.


  10. If you still get an "access denied" or "permission denied" error after
    configuring your DCOM settings, try rebooting your machine to allow the new
    settings to take effect.

For more information on DCOM security enhancements in Microsoft Windows XP
Service Pack 2, see href="http://www.microsoft.com/technet/prodtechnol/winxppro/maintain/sp2netwk.mspx#XSLTsection126121120120"
target=blank>http://www.microsoft.com/technet/prodtechnol/winxppro/maintain/sp2netwk.mspx#XSLTsection126121120120
.





Configuring DCOM on Windows 98


DCOM does not come pre-installed with Windows 98. If you wish to use
J-Integra on Windows 98, you must href="http://www.microsoft.com/com/dcom/dcom98/dcom1_3.asp"
target=blank>download DCOM98 from Microsoft
. In addition, Windows 98 does
not support the automatic launch of a server. Therefore, you must manually start
the COM server you wish to access before running your Java client. If you do not
do this, you will get the following error message:


    AutomationException: 0x80080005 - Server execution failed. Note that
    Windows 95 does not support automatic launch of a server, it must be running
    already.





Network Security: LAN Manager Authentication Level


Microsoft Windows has a setting that determines which challenge/response
authentication protocol is used for network logons. This choice affects the
level of authentication protocol used by clients, the level of session security
negotiated, and the level of authentication accepted by servers.

J-Integra only supports Send LM & NTLM responses. Since
this is the default setting for Windows platforms, this is typically not a
problem for most users. However, if your network administrator has changed this
setting you will probably get an error similar to:


    java.io.IOException: Unable to establish RPC Connection to DCOM SCM on
    192.168.4.202 (Bind returned Bind_NAK)

Please ensure that the LAN Manager Authentication Level is set to Send
LM & NTLM responses
by doing the following:


  1. Click Start, click Settings, click Control Panel,
    click Administrative Tools, click Local Security Policy.
  2. In the Local Security Settings dialog box, click Local
    Policies
    , and then click Security Options.
  3. Double-click Network Security: LAN Manager Authentication Level.
  4. Select Send LM & NTLM responses.
  5. Click OK and exit out of Local Security Settings.

Since J-Integra implements the NT Challenge-Response Mechanism (NTLM) in pure
Java as part of its DCOM engine, user passwords are NEVER sent over the
wire. Microsoft's own documentation verifies this:


* J-Integra only supports Authentication, not
Encryption.





Accessing COM Components Within ATL Services


By default, the Microsoft ATL Service Wizard generates code which initialises
all COM components running within the service to use Packet level
authentication. J-Integra only supports Connect level
authentication (or None), so you will need to modify the generated
code as follows.

The following generated code should be changed from this...


    hr = CoInitializeSecurity(sd, -1, NULL, NULL,
    RPC_C_AUTHN_LEVEL_PKT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE,
    NULL);

To the following...


    hr = CoInitializeSecurity(sd, -1, NULL, NULL,
    RPC_C_AUTHN_LEVEL_CONNECT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL,
    EOAC_NONE, NULL);




References


If you are using Windows Terminal Services, please read...


If you are configuring Microsoft Office applications server-side (e.g.
JSP/Servlet accessing Microsoft Excel), please read...