Bruce,

It looks like you were on the right track initially, the problem is that PHP
has a major bug - odbc_setoption is coded specific to ODBC statement handle
(connection id), which means that trying to use odbc_setoption the way you
want attempts to set a SQLSetConnectOption AFTER the connection is open -
which is bogus and will give you ODBC function sequence errors.

On the other hand, the error message you were getting is a bit misleading;
we are fixing that now.

So... you can unfortunately not do this via Application ID, but since you
are using the OpenLink Rules Book, you can still affect Session-based
connection management with any of the other connection criteria:

Here is one way to do it:
--------------------------------------
Setup your session attributes by configuring the Session Rules Book Aliases
section of the Multi-Tier OpenLink Admin Assistant.
(http://servername:8000).

You can configure session rules for any combination of Domain, Database,
User, Operating System, Client Machine, Client Application, etc., and can
control any connection options at the server side based on the session.

Using "Database" as an example, add a Database Alias with a new database
name and configure a session mapping rule to point to the original database
name, but change the connection attributes from "Read / Write" to "Read
Only" in the options for the  connection session.

On the PHP side, simply choose between two DSN's in the odbc.ini - one is
the "normal" DSN, with default settings, and one will have an alternate
database name, "name_readonly" or somesuch, that will cause the oplrqb to
instantiate the appropriate connection attributes.

If you run into problems, you should probably open a support case at
http://www.openlinksw.com/support/suppindx.htm, as this is getting somewhat
off-topic for PHP.

Hope this helps!

Best regards,
Andrew Hill
Director of Technology Evangelism
OpenLink Software  http://www.openlinksw.com
Universal Data Access & Data Integration Technology Providers





I was thinking of using the usernames, but as people come and go, that might
mean messing around with the oplrqb.ini file too much.  I'd really like to
do
this based on application.  What variable do I pass with the PHP script?
( I'm
not sure what you mean ).  Can I use a variable in PHP that passes the
application name to the server?

Thanks,

Bruce

Andrew Hill wrote:

> Hi Bruce,
>
> The setoption error is being thrown because you cannot use
> SQLSetConnectOption that way.
> Passing arbitrary info to be used by your application isn't really what
this
> is for, but instead can be used to modify parameters in the ODBC API.
>
> This means you can modify things like SQL_ACCESS_MODE, SQL_AUTOCOMMIT,
> SQL_ODBC_CURSORS, etc., (check the 2.x spec - there are several metadata
> items that you can control with this API call.)
>
> I'd recommend you just pass a variable to your PHP script, and perhaps
> change the username to a read-only/read-write user with  a case statement
or
> somesuch, based on the application.
>
> Again, I'd strongly recommend you upgrade the OpenLink UDA version as
well;
> 1.5 is something like 5 years old or more.
>
> Best regards,
> Andrew Hill
> Director of Technology Evangelism
> http://www.openlinksw.com/virtuoso/whatis.htm
> OpenLink Virtuoso Internet Data Integration Server
>
> > -----Original Message-----
> > From: Bruce S. Garlock [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, March 25, 2002 10:48 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [PHP-DB] ODBC -- Setting ApplicationID
> >
> >
> > Sure, I'm simply trying to have PHP pass an ApplicationID to the
> > ODBC server.
> > When a PHP script access the ODBC database, it does not set the
> > application:
> >
> > 10:46:04   connectopts= user=webuser opsys=unix machine=linux
application=
> >
> > As you can see, application= is NULL.  I would like the script to pass
> > something, so that my mapping rules on the server would allow
> > write access to
> > the db, if the PHP application sends a certain name.  Currently our
Win32
> > applications, like MS Access, send application names.  e.g. Access,
sends:
> > application=MSACCESS.
> >
> > Thanks for your help,
> >
> > Bruce
> >
> > Andrew Hill wrote:
> >
> > > Bruce,
> > >
> > > I'm not sure what you are trying to do - could you clarify?
> > > You may be able to simply use the OpenLink Rules Book to set
role-based
> > > authentication on domain, ip, application, etc.
> > >
> > > Also, the ODBC Driver version (1.5) you are using is _very_ old and
> > > unsupported.
> > > I suggest you upgrade to 4.2
> > >
> > > Best regards,
> > > Andrew Hill
> > > Director of Technology Evangelism
> > > OpenLink Software  http://www.openlinksw.com
> > > Universal Data Access & Data Integration Technology Providers
> > >
> > > > -----Original Message-----
> > > > From: Bruce S. Garlock [mailto:[EMAIL PROTECTED]]
> > > > Sent: Thursday, March 21, 2002 11:02 AM
> > > > To: [EMAIL PROTECTED]
> > > > Subject: [PHP-DB] ODBC -- Setting ApplicationID
> > > >
> > > >
> > > > I am trying to set the ApplicationID, when connecting to an ODBC
> > > > datasource.  I have tried:
> > > >
> > > > odbc_setoption ($conn, 1, 1053, "PHPAPP");
> > > >
> > > > And get a:
> > > >
> > > > "SQL error: [iODBC][Driver Manager]Option type out of range, SQL
state
> > > > S1092 in SetConnectOption"
> > > >
> > > > Basically, I want my PHP script to pass the application name
> > to the ODBC
> > > > server, so that I can set up a mapping on the server that allows
write
> > > > access when a certain application string is sent.
> > > >
> > > > PHP 4.06 (with file-upload patch)
> > > > Openlink ODBC 1.5
> > > > Linux Client
> > > > SCO Informix 5 server
> > > >
> > > >
> > > > TIA-
> > > >
> > > > Bruce









-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to