CA Service Management

Expand all | Collapse all

ITAM SAM Database Connection Failure

  • 1.  ITAM SAM Database Connection Failure

    Posted Jun 25, 2015 04:02 PM

    Encountered a DB connection issue with ITAM SAM 12.8. Recommendation was to move to 12.9. Yet the same error message occurs with 12.9 setup implying that SAM is unable to reach the database, yet database is fully reachable.

     

    Details:

    • DB = MS SQL 2008
    • No firewall rules between SAM server and DB Server.
    • Server: Win 2K8 R2

     

    Known:

    • SAM is unable to successfully connect to database.
    • I am able using either SQL tools or "TestDatabase.UDL" file to manually connect to the SAM DB and also query said DB tables.
    • There are no firewalls blocking any traffic between SAM/DB servers.

     

    Unknown: What exactly is causing the issue...

     

    Screen cap of result during processing.

    ErrorCapture.jpg

     

     

     

    Has anyone seen this error message before? Any obscure logs I should be checking?



  • 2.  Re: ITAM SAM Database Connection Failure

    Posted Jun 25, 2015 04:29 PM

    What version of PHP are you running?  What release of SAM (3.6.6)?  Are you using Zend Server?  What version of the SQL PHP Driver? And what version of SQL Server?



  • 3.  Re: ITAM SAM Database Connection Failure

    Posted Jun 29, 2015 03:34 PM

    Apologies, those details would definitely be useful.

     

    • PHP Version: 5.4.24
    • SAM version: I believe is 3.5.5 (the version included as part of CA IT Asset Manager 12.9 package.)
    • Zend Guard Loader 5.5.0
    • PHP Driver used: php_sqlsrv_54_nts.dll (to match PHP version)
    • SQL Server: Microsoft SQL Server 2008 R2 (SP3) - 10.50.6000.34 (X64)  Aug 19 2014 12:21:34  Copyright (c) Microsoft Corporation  Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)
    • SQL tools are installed directly on the SAM server.

     




  • 4.  Re: ITAM SAM Database Connection Failure

    Broadcom Employee
    Posted Jun 30, 2015 05:07 AM

    Did you create a database for CA SAM prior to running the setup? Are there any errors in SQL ERRORLOG or Windows logs of the database server (Application or Security) around the time you attempted to run SAM setup?

     

    I see you have installed SQL Client Tools on the SAM server, but can you confirm SQL Server Native Client is also installed?

     

    If this post is not helpful I would advise you to raise a support case for assistance so we can look further into the problem.



  • 5.  Re: ITAM SAM Database Connection Failure

    Posted Jun 30, 2015 09:51 AM

    Yes the database is called SAM_Prod, it is present in the DB and the user was setup as per instructions.

     

    The SQL Client Tools and SQL Server Native Client are installed on the SAM server.

     

    I'm looking to see if I can find anything in the SQL server's logs.



  • 6.  Re: ITAM SAM Database Connection Failure

    Posted Jun 30, 2015 01:55 PM

    The SQL ERRORLOG contains no errors. I've reviewed the Application/Security and System logs, no errors/warnings in any of these, be it on the DB or SAM server.

     

    I'm following the instructions provided by support... at this point I just need to figure out why same believes it can't connect to the database, when in actuality the database is alive and well and connectable. (There's no firewalls or anything else preventing connectivity)



  • 7.  Re: ITAM SAM Database Connection Failure

    Broadcom Employee
    Posted Jul 01, 2015 09:34 AM


  • 8.  Re: ITAM SAM Database Connection Failure

    Posted Jul 02, 2015 09:46 AM

    The database and user are both setup correctly. I've reviewed and confirmed both.  Using a test datalink I can confirm I can connect to SAM_PROD db successfully using the same credentials being passed by SAM.

     

    connection success.JPG

     

     

    The SQL server log shows a successful login for user in the logs.

    Based on my troubleshooting steps I believe PHP is the culprit here. I've eliminated SAM out of the equation and am testing with a simple PHP script to connect using same MSSQL details/credentials as would be passed by SAM. What is odd here is SQL server log is showing a successful login, however PHP is reporting connection couldn't be established. So it would seem the connection issue is at the PHP level...

     

    I've re-downloaded the PHP driver, just in case it was somehow corrupted. I'm also currently going back through the PHP.INI to see if something might be out of place. 



  • 9.  Re: ITAM SAM Database Connection Failure

    Broadcom Employee
    Posted Jul 02, 2015 12:09 PM

    Ok, please let us know what you find out.

     

    Are you using named instance in MS SQL or the default instance?



  • 10.  Re: ITAM SAM Database Connection Failure

    Posted Jul 02, 2015 02:21 PM

    The default instance.

     

    I did note that the DB server I'm trying to connect to does not get reported when I run: sqlcmd -L



  • 11.  Re: ITAM SAM Database Connection Failure

    Posted Jul 07, 2015 05:52 PM

    We could use a confirmation of the PHP call SAM is making to connect to the database to help us troubleshoot.



  • 12.  Re: ITAM SAM Database Connection Failure

    Posted Jul 08, 2015 09:55 AM

    Using simple PHP script to establish connect to and query SAM_PROD DB the following occurs using the following method:

     

    Note: In both cases I'm using the exact same script file.

     

    • Browser:
      • Connection Failed.
        • no error messages are produced beyond this.
        • I get confirmation of connection failure if I add a "echo "connection failed"; otherwise it's just blank...

     

    • Command Prompt
      • Connects and returns results of query successfully.

     

     

    I've gone through my IIS settings between DEV/PROD and both are, as far as I can tell identical, unless I'm missing something obscure.

    Only difference I came across was that in Dev IUSR has read access to PHP folder, I revoked it's rights in Dev, and no issues occured.

     

    *edit* Sorry wanted to include the script used:

     

    <?php
    
    
    $serverName = "dbNAME";
    $user = "user";
    $passw = "paSSWORD";
    $db_name = "SAM_PROD";
    $connInfo = array( "Database"=>"$db_name", "UID"=>"$user", "PWD"=>"$passw"); 
    $conn = sqlsrv_connect( $serverName, $connInfo);
    sqlsrv_configure("WarningsReturnAsErrors", 1);
    
    
    if( $conn === false ){
        die(print_r( sqlsrv_errors(), true));
    
    
    }
    
    
    $sql = "SELECT * FROM SAM_PROD.DBO.users";
    
    
    $stmt = sqlsrv_query( $conn, $sql );
    if( $stmt === false ) {
        if( ($errors = sqlsrv_errors() ) != null) {
            foreach( $errors as $error ) {
                echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
                echo "code: ".$error[ 'code']."<br />";
                echo "message: ".$error[ 'message']."<br />";
            }
        }
        
    }else{
         echo "Connection established.\n";
         echo "Rows returned: \n";
    
    
    while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
          echo $row['login']." , ";
    }}
    
    
    ?>
    
    
    
    
    


  • 13.  Re: ITAM SAM Database Connection Failure

    Posted Jul 08, 2015 11:50 AM

    Here is an MSDN article that may help capture the connection in errors in a way that may be visible from the browser:

     

    How to: Handle Errors and Warnings Using the SQLSRV Driver

     

    <snip>

    /* If the connection fails, display errors and exit the script. */

    if( $conn === false )

    {

      DisplayErrors();

      die;

    }

    <pins>

     

    If that doesn't work we may have to set the results of DisplayErrors() in to a variable and echo the variable.



  • 14.  Re: ITAM SAM Database Connection Failure

    Posted Jul 08, 2015 08:33 PM

    Here's what I get when I add the snippet into the script

     

    PHP Fatal error: Call to undefined function DisplayErrors() in C:\inetpub\wwwroot\DBTEST.PHP on line 11

     

    Simplified the script to only connect and try to capture the error.

    <?php
    
    
    $serverName = "server, 1433";
    $connectionInfo = array( "Database"=>"SAM_PROD", "UID"=>"USERNAME", "PWD"=>"PASSWORD"); 
    $conn = sqlsrv_connect( $serverName, $connectionInfo);
    sqlsrv_configure("WarningsReturnAsErrors", 1);
    
    
    /* If the connection fails, display errors and exit the script. */
    if( $conn === false )
    {
      DisplayErrors();
      die;
    }else{
      echo "Success!";
    }
    
    
    ?>
    
    


  • 15.  Re: ITAM SAM Database Connection Failure

    Posted Jul 09, 2015 09:04 AM

    Additional note. I used var_dump to get the output of the variables used.

     

    $conn consistantly returns : bool(false)

    In IIS FastCGI is using PHP_CGI.EXE. As setup by the original install.

     

    From a command prompt the following is returned based on the executable used:

    CMDPrompt Success.JPG



  • 16.  Re: ITAM SAM Database Connection Failure

    Posted Jul 06, 2015 12:20 AM

    Hi, I am working with Marc on this issue.  The primary issue seems to revolve around the way that SAM connects to the MSSQL server.  We know that another environment is able to connect to the database server, and the application files were copied when the upgrade was performed (so there should be no difference between the files in the two environments).  We could use a confirmation of the PHP call SAM is making to connect to the database to help us troubleshoot.  We will be investigating the sqlsrv_connect() call in PHP, but without access to the code base this is a WAG.