Wednesday, November 6, 2013

Hidden share

A network share on a Microsoft network that is not visible when viewing another computer's shares; however, it is still accessible if the name of the hidden share is known.
Default Microsoft Windows hidden shares
Below are examples of Microsoft Windows default hidden shares.
ADMIN$ - The default systemroot or Windows directory.
C$ and x$ - The default drive share, by default C$ is always enabled. x$ represents any other partitions or drives found by Windows that will also be shared, e.g. D$, E$, etc.
FAX$ - Share used by fax clients to access cover pages and other files on a file server.
IPC$ - See the IPC definition for additional information about IPC.
PRINT$ - Share used by printers, enabling remote administration on printers.
Creating a Microsoft Windows hidden share
A Microsoft Windows hidden share is created by adding a "$" at the end. For example, if the share was "hope", adding a "$" to the end of hope, so the shared name is "hope$", will make a hidden share.
Accessing a Microsoft Windows hidden share
Assuming we were attempting to access the "hope$" share that we created in the above example from another computer we would type the below network path to access the hidden share.
//<computer_name>/hope$
Viewing Microsoft Windows hidden shares
Hidden shares give users a false impression that the share cannot be found unless it is known. Although this may be true for most users, a user can use dozens of utilities available on the Internet to view all shares, regardless if they are hidden or not. If you are creating a hidden share to protect sensitive data, password protect the share instead of making it hidden.
An easy method for users to display any hidden shares on their computer is to use the net use command.

Friday, October 25, 2013

Troubleshooting & diagnosing TNS SQL*Net connectivity errors


There are a variety of common network connectivity error messages, and most DBA's have seen TNS error messages these at sometime in their careers.  Here is just a small sample of possible TNS network connectivity-related errors:
  • TNS-12545: Connect failed because target host or object does not exist
  • ORA-12154: TNS: Could not resolve service name
  • ORA-12157: TNS Internal network communication error 
Steps to troubleshoot Oracle connectivity:
To troubleshoot & diagnose Oracle connectivity problems, I like to start at the simplest, outermost level, and follow this checklist:
  1. Check with "ping" using the IP address ("ping 1.1.4.3")
  2. Check with "ping" using DNS name (e.g. "tnsping database")
  3. Try telnet to the IP on port 1521 (telnet 1.2.3.4 1521)
  4. Check with "tnsping" using TNS service name
  5. Invoke SQL*Plus from the OS command line "sqlplus abcd@database".  If this fails, check to ensure that your listener has the database service defined.
  6. Sign-on to SQL*Plus and connect with the TNS name
  7. Within SQL*Plus, try a select * from table


    Above mentioned steps are the first sign of checking the connection error. My server was able to clear all the above seven steps. Still I am not able to connect to database via my application. Then I changed my sqlnet.ora. There were multiple entries, to which I reduced them to a single line

    names.directory_path= (tnsnames)

    Then on investigation I found out, the code that was causing trouble is:

    SQLNET.AUTHENTICATION_SERVICES = (NTS)
    names.default_domain = world

    So even if I commented these two lines in my original sqlnet.ora, it worked. Hope this works for you as well.






Monday, October 21, 2013

ALL_TABLES versus ALL_ALL_TABLES

What's the difference between ALL_TABLES and ALL_ALL_TABLES

Answer
1) Both views provide all tables to which the current user has access to but, in addition to the tables returned by ALL_TABLES, the ALL_ALL_TABLES will also return all object tables (system generated or not) accessible by the current user.

SQL> select *
  2    from dictionary
  3   where table_name in ('TABS','ALL_TABLES','ALL_ALL_TABLES')
  4  /

TABLE_NAME           COMMENTS
-------------------- ------------------------------------------------------------------------------------------------
ALL_ALL_TABLES       Description of all object and relational tables accessible to the user
ALL_TABLES           Description of relational tables accessible to the user
TABS                 Synonym for USER_TABLES


2) The following 3 columns that appear only in ALL_ALL_TABLES, but not in ALL_TABLES 
give you details about the object type on which the object table was created and the object identifier type used: 

OBJECT_ID_TYPE 
TABLE_TYPE_OWNER 
TABLE_TYPE 

If you want to see the difference only between the two views, you can use a select like
the following: 

SELECT * FROM ALL_ALL_TABLES 
WHERE TABLE_TYPE IS NOT NULL 


Even if you don't have object tables in your schemas, you will probably still see some of the object tables used by different Oracle features installed, like XDB, a.s.o. 

3) ALL_ALL_TABLES includes object tables as well as relational tables.


Also, this may be an interview question (e.g. how can you get all tables you have access to?) and you may leave a good impression if you respond with another question: "Do you also want object tables to be included?". :)

Tuesday, October 15, 2013

How to Debug or Test your Windows Service Without Installing it

When you develop a Windows Service and want to run or debug it, you get a message box with this message:
Cannot start service from the command line or a debugger.
A Windows Service must first be installed (using installutil.exe)
and then started with the ServerExplorer, Windows Services 
Administrative tool or the NET START command.
So for testing you have to first install it on your computer, but it is a long process and also boring because every time you make changes, you have to reinstall your service and test it again.

There are many ways it can be done, but I opted this way out becuase of its simplicity.....

For debugging or testing your service without installing it, make changes in Program.cs like this.
static class Program
{
    static void Main()
    {
        ServiceBase[] ServicesToRun;
        ServicesToRun = new ServiceBase[] 
 { 
      new MyService() 
 };
        ServiceBase.Run(ServicesToRun);
    }
}
Change it to:
static class Program
{
    static void Main()
    {
        #if(!DEBUG)
           ServiceBase[] ServicesToRun;
           ServicesToRun = new ServiceBase[] 
    { 
         new MyService() 
    };
           ServiceBase.Run(ServicesToRun);
         #else
           MyService myServ = new MyService();
           myServ.Process();
           // here Process is my Service function
           // that will run when my service onstart is call
           // you need to call your own method or function name here instead of Process();
         #endif
    }
}
After adding #if and #else to your main fuction, now when you press F5 or run your service, it will not show you the previous message and simply run, so attach a break point to your method which will be called by the service when it will start. With the use of this code, you can simply debug your service without installing it.
For this no need to add any extra using directive (like using System.Data or using System.IO) to your class file. It will simply as it is.

'installutil' is not recognized as an internal or external command, operable program or batch file.


You get this error when you type 'installutil.exe' in a command prompt.
Reason: .net folder path is not set in the 'PATH' variable because of which location of installutil.exe was not found.

Resolution:

a) Use the visual studio command prompt, it will work there
b) Set .NET folder path in system's 'PATH' variable . Then try it should get the path of 'installutil.exe' and you can use it directly in any command prompt.

c) Use Coding
It's is really easy to just add it to the service itself. Add a reference to System.Configuration.Install and then update your Main()-function in Program.cs like this.
static void Main(string[] args)
{
    if (Environment.UserInteractive)
    {
        string parameter = string.Concat(args);
        switch (parameter)
        {
            case "--install":
            ManagedInstallerClass.InstallHelper(new[] { Assembly.GetExecutingAssembly().Location });
            break;
            case "--uninstall":
            ManagedInstallerClass.InstallHelper(new[] { "/u", Assembly.GetExecutingAssembly().Location });
            break;
        }
    }
    else
    {
        ServiceBase[] servicesToRun = new ServiceBase[] 
                          { 
                              new ValidatorService() 
                          };
        ServiceBase.Run(servicesToRun
Then you can just call WindowsService1.exe with the --install argument and it will install the service and you can forget about InstallUtil.exe.

Monday, October 14, 2013

Error saying "The 'DisplayGroupTree' property cannot be set declaratively"

Public Property DisplayGroupTree As Boolean’ is obsolete.

In this version Crystal Reports can have a parameter panel. I now have to tell crystal reports what will be displayed in the left panel:

  • the group tree
  • the parameter panel
  • nothing

The parameter is ToolPanelView. If you don’t want to show nothing in the left panel:
rptViewer.ToolPanelView = CrystalDecisions.Windows.Forms.ToolPanelViewType.None

Thursday, September 19, 2013

Retrive password from Toad for Oracle

One of the oldest feature Toad has is saving login passwords. This is accomplish easy with enabling check box "Save passwords" on login screen. 
The whole connection process is defined through three files located in %USERPROFILE%\AppData\Roaming\Quest Software\Toad for Oracle\11.6\User Files\, where "11.6" is Toad version and may vary in your cases: 
  1. CONNECTIONS.INI
  2. CONNECTIONACTIONS.INI
  3. CONNECTIONPWDS.INI
Passwords are stored in encrypted way in CONNECTIONPWDS.INI file. However they are not exposed in any normal way (you can read them) but only to use them as login without knowing password, which was once placed. But having stored passwords allow Toad many beautiful automation and wide a lot actions that might need password as input. 

The solution

The trick is based on another Toad for Oracle feature-get SQL for any kind of DDL action, which was performed through GUI, in this case creating db link. Here is what you have to do to retrieve scott password:
  1. Choose Database|Create|DB Link menu item
  2. Fill the Link Name and Database data as shown in the picture:

  3. Click on 'Set user/Pass to current'
  4. As you can see I have chosen scott user and password is automatically retrieved from saved passwords file.
  5. Choose Show SQL as shown in the picture and you'll get pure SQL which contains password
The trick is working for every user's password. 

Someone might say this is security issue, but I think it is not! Mentioned file with stored passwords is encrypted with two keys:

  1. Domain user name
  2. Some kind of workstation unique hash value
These ensures that password file cannot be copied to another workstation and Domain admins (or other privileged users on that workstation) cannot use that file in any way!