Re: Pear::DB - with MS SQL - Cannot access VIEW of Active Directory.
| From: | Justin Patrin | Date: | Wed, 13 Oct 2004 05:42:01 +0000 |
| Subject: | Re: Pear::DB - with MS SQL - Cannot access VIEW of Active Directory. | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-14889@lists.php.net to get a copy of this message | ||
On Wed, 13 Oct 2004 14:47:18 +1000, laurence <laurenceh@iprimus.com.au> wrote:
> Hello all.
>
> We have MS SQL Server 2000 running on Win 2003 Server. Using PEAR DB to
> access tables - no problem. Problem is with VIEWS
>
> MS SQL Server allows you to setup other servers as LINKED SERVERS, including
> LDAP servers like Active Directory on the same machine.
> We have a view of Active Directory data, which when accessed, causes SQL
> Server to do its own LDAP retrieval from Active Directory, and present data
> just like any other view or table. Problem is that Pear DB cannot access it,
> with msg:
>
> DB Error: unknown error.
>
> Are there known issues with DB accessing views generally?
> Are there known issues when DB used with MSSQL, or with views in MSSQL?
>
> No particular code is relevant here, but here is an example.
>
> _________________________________________________
> $db_user = 'exampleUserID';
> $db_pass = 'examplePW';
> $db_host = 'localhost';
> $db_name = 'ExampleDBName';
> $db_engine = 'mssql';
> ////////////////////////////////////////////////////////////////////////////////
> require_once 'DB.php'; // require PEAR::DB classes
>
> // Datasource in this style: dbengine://username:password@host/database
> $datasource = $db_engine . '://' . $db_user . ':' . $db_pass .
> '@' .
> $db_host . '/' . $db_name;
>
> // attempt connection
> $db =& DB::connect($datasource);
>
> // if connection failed show error
> if(DB::isError($db)) {
> die("PHP - 'db_connect.php' Pear DB::connect() failure.
> ".$db->getMessage());
> }
>
> $sql = "SELECT DN FROM ActiveDirectoryUsers WHERE UserID =
> '{$_SESSION['user']}'";
> $res =& $db->query($sql);
> if (DB::isError($res)) die("PHP: 'exampleFile.php' Query 1 Failure.
> ".$res->getMessage());
Try adding $res->getUserInfo() to your output here. It will give the
actual error from the DB.
> _____________________________________________________________________
>
> Thanks in advance for any insight.
>
> Laurence
>
--
paperCrane --Justin Patrin--