Update Active Directory from PHP - php

I have linked SQL Server into Active Directory and am trying to use PHP to create an ODBC connection to pull in the data. I can read from Active Directory fine but when I try and update it using SQL UPDATE, I get this error
Msg 7390, Level 16, State 2, Line 1
The requested operation could not be performed because OLE DB provider "ADSDSOObject" for linked server "ADSI" does not support the required transaction interface.
I know I have to use PHP's LDAP functions but I am not sure how to rewrite the LDAP string to use in PHP. My best guess would be:
I tried (example string):
OU=staff,DC=example,DC=internal
but this doesn't work. My question is: assuming there is no way of updating Active Directory from my SQL view, how do I go about updating LDAP with PHP?

Related

Getting error messages while connecting to snowflake database though ODBC

I am using Ubuntu, I am trying to connect php to snowflake using ODBC driver, I have added driver information in /etc/odbcinst.ini. Here is the driver information, that I am using
[ODBC Drivers]
SnowflakeDSIIDriver=Installed
[SnowflakeDSIIDriver]
APILevel=1
ConnectFunctions=YYY
Description=Snowflake DSII
Driver=path-to-"libSnowflake.so"
DriverODBCVer=03.52
SQLLevel=1
ErrorMessagesPath=path-to-folder-which-has-error-message-xml-files
I am getting error two erros
The error 1 : SFRestRequestFailed could not be found in the en-US locale. Check that /en-US/SFMessages.xml exists.
The error 2 : REST request to the Snowflake is failing(I got this error by checking corresponding message attached to 'SFRestRequestFailed' in SFMessages.xml).
But I am able to connect Snowflake and fetch data using same access details in windows.
Kindly share your ideas to resolve this issue.
Thank you
ErrorMessagePath is a snowflake configuration. If you use the snowflake odbc package for linux, you will find unixodbc.snowflake.ini or iodbc.snowflake.ini which you can use accordingly depending on which driver manager you are using. ErrorMessagePath should be set in unixodbc.snowflake.ini or iodbc.snowflake.ini and your SIMBAINI env var should be set to point to one of these files.

Load *LIBL (library list) defined in CRTJOBD when connecting to db2 with PDO

It seems nobody had this problem yet.... With db2_connect I found docs that decrible how to load a default library list (*LIBL) on connection but with PDO nothing!
I'd like to perform statements without specifing always the library name in front of file name. I already created a JOB DESCRIPTION to load the libraries, and when I log in with the PC5250 emulator those library are online.
But if I run a query with PDO without specifying the library name following is returned:
Error executing sth in testGet for AS400 SQLSTATE[42S02]:
Base table or view not found: 0
[IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL0204 -
TESTFILE in WEB type *FILE not found.
(SQLPrepare[0] at ext\pdo_odbc\odbc_driver.c:206)
To use the library list, you will need to make sure your connection attributes specify system naming, and I would avoid setting a current schema.
Without much knowledge of PHP + PDO, the stackoveflow tag wiki gives a good introduction. Check that PDO is configured for proper settings for DB2 for i, not LUW or z. Likewise check db2_connect settings. (Why are you using that, instead of straight ODBC?)
I know it's been awhile since you posted but I came across some info on how to do library lists using the PDO driver... see http://yips.idevcloud.com/wiki/index.php/XMLSERVICE/PHPPDOChangeLog.
So for example you could do something like this:
$options = [
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_AUTOCOMMIT => true,
PDO::I5_ATTR_DBC_SYS_NAMING => true,
PDO::I5_ATTR_DBC_LIBL => "LIB1 LIB2 LIB3",
];
$db = new PDO("ibm:SYSTEM", "user", "password", $options);
Keep in mind this will probably require a recent Zend Server (since Dec 2014). I know the latest stuff is in the new ZS 8.5 but I'm not sure about older releases.
You might also be able to leave off the library list option - in my limited testing this appears to let it use the library list from the job description. I'm not sure about the current library and YMMV but I'd be curious to hear back if it works for you or not.
Also for what it's worth an email address for the official maintainer is listed on http://pecl.php.net/package/PDO_IBM. Questions could also be sent to the WEB400 mailing list (http://lists.midrange.com/mailman/listinfo/web400), I think people who are involved in the development of the pdo_ibm driver are on there as well.
If you're talking about these docs, then that is if you're using PDO_IBM on IBM i. I don't think those settings are supported on any other platform. From your error message, it seems that you are using the IBM i Access ODBC driver through PDO_ODBC. The IBM i Access ODBC driver connects to a QZDASOINIT prestart job running in QUSRSYS subsystem. If you want those jobs to use a different job description, you need to use CHGPJE to change it: CHGPJE SBSD(QUSRSYS) PGM(QSYS/QZDASOINIT) JOBD(MYLIB/MYJOBD). If you're using SSL connections, also change QZDASSINIT jobs. You'll need to end any existing QZDASOINIT/QZDASSINIT jobs and the new pre-start jobs will pick up the new settings. Note that this will affect all ODBC, JDBC, OLEDB, .NET connections for IBM i Access drivers.
You can configure the library list through the DSN as well, by setting the DBQ connection string or DefaultLibraries ODBC.INI setting or setting the "Library List" value under the Server tab from the DSN configuration GUI on Windows.

run an update on a linked MS Access table using php

I have Microsoft Access Database (mdb file) with a table in it (we'll call that table A) that is linked to another Microsoft Access Database (we'll call that table B). I need to be able to update table A using php (which will in turn update table B, since A is linked to B). Please note that the table I'm linking to has a primary key named "Intersection" and it is set to Indexed: Yes (No duplicates).
If I use a simple odbc_connect and odbc_exec to run the following query:
$con= odbc_connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$mdbFilename", $user, $password)
$res = odbc_exec($con, "UPDATE tableA SET myfield=NULL WHERE myfield=2439;");
However, when I try this on a database with a linked table, I get the following error:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC
Microsoft Access Driver] Operation must use an updateable query., SQL
state S1000 in SQLExecDirect in G:\web\libs\test.php on line 413
For some reason it seems that my database is not updateable even though it should be. It has a primary key defined and is a simple table (except for the fact that it's linked). Originally I was getting the following error:
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC
Microsoft Access Driver] 'H:\test\Database\test.mdb' is not a valid
path. Make sure that the path name is spelled correctly and that you
are connected to the server on which the file resides., SQL state
S1009 in SQLExecDirect in G:\web\libs\test.php on line 413
But then I changed my linked table so instead of using drive letters to navigate to the linked table, I used the absolute \server\ path, which seemed to fix that problem, however not it is not able to be updated.
In case it helps, to create the Linked table, all I did was (Using MS Access 2010) I hit the "External Data" tab, then the "Access" (button), then I made sure to hit "Link to the source by creating a linked table" (option) and I selected the other database which contains the original table.
Is there some way to run an update on a linked access table using php?
Again, if you have a MS Access linked table that is linked to another table, and these tables have a primary key that is properly indexed. You CANNOT update the table using the following above PHP code (even though it works completely fine on an table which is not linked).
Please note, I have tested this with a fresh accdb database file as well, and if it is a linked table, it seems it will become read-only if you try to update the table using odbc_exec, however it does return data just fine, I just can't insert or update records.
Thank you.
[UPDATE]
Our server is running Windows Server 2003 with apache, and php. So I set up a Windows 7 machine with apache, and php, and it IS able to update a linked database without a problem, so I suspect my problem (since it's the only difference between the machines that could affect this), is that the Win2003 server is running odbc v3.5 whereas my win7 Machine is running odbc v6.1. I'm still looking into this further and will update this post if I find a solution to getting it working on our Windows Server 2003 machine.

CDbCommand failed to execute the SQL statement when deploying to a server

I really don't know what causes this error.
CDbCommand failed to execute the SQL statement: CDbCommand failed to prepare the SQL statement: SQLSTATE[HY000]:
General error: 1 table 'YiiSession' already exists. The SQL statement executed was:
CREATE TABLE 'YiiSession' (
"id" CHAR(32) PRIMARY KEY,
"expire" integer,
"data" BLOB
)
Is it in the server or in yii..
but i guess it is in the yii part.
but what configurations did i miss?
i'm not really familiar with yii because im new to it.
any help please?
Thanks in advance
UPDATE: I check YiiSession in my database but it is not in there...
Delete the runtime folder.
Because runtime folder is used by the system for various tasks: session, logging etc.
It is also in the runtime folder that YiiSession table is created
In case anyone is still referencing this - the more complete answer is that Yii uses a SQLite3 database by default if you don't specify a connection string in your (CDbHttpSession) session config. This SQLite db is created in the runtime folder. (Which is why deleting the contents of the runtime folder works - you actually only need to delete the session-x.x.xx.db file.) If you want to use the same database you are using for your main connection, add:
'connectionID'=>'db',
to your session config. It's also recommended for production use you set autoCreateSessionTable to false, which will also prevent the error - you just need to make sure you deploy the SQLite db or set up the proper table in your main db. see here
By default, it will use an SQLite3 database named 'session-YiiVersion.db' under the application runtime directory. You can also specify connectionID so that it makes use of a DB application component to access database.

php using msaccess

Because no one answer my question Codeigniter using ms access database , i make new question i not using codeigniter
if I using mdb from my computer it works but if i using mdb from another computer in my network
i got error this is my CODE
<?php
$connect = odbc_connect("testdb", "", "");
$query = "SELECT * FROM ACGroup";
$result = odbc_exec($connect, $query);
while(odbc_fetch_row($result)){
$name = odbc_result($result, 1);
echo("$name");
}
?>
i make odbc where the data its from another computer in my network
"testdb" are data sourcename and database \\ip\folder\testdb.mdb
and i got this error
Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Microsoft Access Driver]
The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data.,
SQL state S1000 in SQLConnect in D:\blabla\coba.php on line 3
I already try folder setting but it not work
The ODBC connection string you are using ("testdb") does not even specify a database driver, much less a database file. You will need to read up on the appropriate format for $dsn. (The php.net page even has a few examples for Access files.)
The problem possibly lies in the permissions your Apache user has on the mdb file.
Go to your mdb file, right-clik on the file -> Properties ->Security tab and see if your Apache user is on the User Groups that have access/control on the mdb file.
In order to see/change your Apache user, go to Control Panel-> Administrative Tools -> Services, right-click on Apache service -> Properties -> Logon tab. In the Log on as option, see if the user selected belongs to the User Groups that have access to mdb file. If not, create one and add it to the User Groups and then use it as the Apache account.

Categories