Problem:
I am building a RESTful API. The DBA I'm working with has set up an MSI for gaining access to the production database, which is on an Azure SQL instance. I understand that MSI's are token based, and on https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/tutorial-windows-vm-access-sql, it has an example written in C#. This does not translate to PHP well, mostly because of my unfamiliarity with C#.
In addition, I am using Lumen to develop the API, which uses PDO for handling the connections. As far as I know, PDO does not have the necessary functionality built in to handle the specialized connection string Azure SQL requires for using an MSI. See Azure Sql Db connection string when using MSI
Previous research:
I've read just about every article Microsoft has published about managed identities, and scoured the internet for anyone using managed identities in PHP. Needless to say, the pickings are slim, even more so for this particular use case.
I understand that one could use Key Vault and store the connection string as a note, but I'm 99% sure the system admins won't want this to happen. What's the point in having the MSI if we're still going to have credentials stored somewhere else?
Worst case, I suppose I could make the proposition that I need to use a traditional user/password auth flow, despite the powers that be wanting all new projects to use MSIs (we're predominantly a Microsoft shop with a small portion of PHP work).
Posting this is my last ditch effort before presenting my proposition to use Key Vault instead for, at very least, storing the production credentials; the idea of storing a connection string is an anti-pattern in my opinion.
Fundamentally, if someone could provide an example PDO connection string (sqlsrv driver) using an MSI, it would probably move me in the right direction. Any other examples one could provide, or even guidance for how I can use the MSI in this context would be greatly appreciated.
Per https://learn.microsoft.com/en-us/sql/connect/php/azure-active-directory?view=sql-server-ver15, PDO does have the required functionality. Answering this as the scope of the original question has shifted too far from its original focus.
I now have a support question opened at https://github.com/laravel/framework/discussions/33678 to determine the best method of utilizing an MSI in Laravel as there is no apparent way to do so based on the code/documentation.
Related
I'm trying to connect a web portal coded in PHP to a Sharepoint database. I researched and there are 2 possible options to use: MSSQL 2005 OBDC Driver and Webservices.
Which of this 2 options is the better one, and why?
https://technet.microsoft.com/en-us/library/cc793139(v=sql.90).aspx
This is an easy answer. The answer is the web services because directly querying SharePoint's databases is not allowed from a supportability standpoint (reference: https://blogs.msdn.microsoft.com/brian_farnhill/2013/12/04/directly-querying-sharepoint-databases/)
To summarize some of the core arguments is that directly talking to the database (even if it is just reads) introduces unpredictable locking of database resources which will cause problems. On top of this, the Content Database schema is not the best of my knowledge formally documented and of course subject to frequent changes. If you've ever peered inside you'll see that it is quite complicated and thus difficult to come up with generic SQL to get the data you want. The API (and therefore the web services) have done the hard work to give you a generic interface into SharePoint and to hide the complexity.
Lastly, if you are at all thinking about modifying SharePoint you are an absolute glutton for pain if you think about using direct SQL.
I have a database in Access I need to access a Microsoft Access database via the internet and am building a PHP interface. I would like to know if it would be better to convert to MySQL or Microsoft CRM Dynamics as would they be faster?
My other question is can MS Access or MS Dynamics even be accessed via PHP PDO currently? If not my first questions is redundant and MySQL is the way to go.
Regards,
Max
Short answer:
it certainly makes sense to migrate your data into a normal relational database system, regardless if that is MariaDB, MySQL, PostgreSQL or whatever. Many advantages exist besides performance, for example you get rid of the vendor lock in and have free access to your data the way you want to. This includes using php to access that data. Is there any reason against migrating it? I mean reasons expect "we always used MS-Access" or the like...
And I never heard of a reliable and stable MS-Access driver for PHP.
Hi all i am a Student working on a project in an Hospital we designed an application where patient can book an appointment with doctor similar to this application (apphp.com/php-medical-appointment/examples/sample2/index.php) and our application uses php and mysql and runs on microcms framework now what we are trying to do is to get this application integrated with MedTrak (http://www.intersystems.com/trakcare/) which uses CACHE DB (Intersystems Cache db a post relational db)
we have written our application using mysql so is there any possible ways that we can fire data from our application to their db and. get, data from their db
So far we have tried these methods
odbc will it work cause we have to write our application in ODBC again
Help
Enterprise Application Patterns is a great book and I highly recommend it. However, I would add that even if you had top notch messaging middle-ware available to ensure the 2 applications are as loosely coupled as possible, at some point you will have to read or write to the Cache database, and you will probably need both.
Also, a sophisticated approach to integration may or may not be feasible on a student project. Perhaps it would be sufficient to have most of your code talk to an abstract communication layer that encapsulates the exact integration? You could start with whatever is simplest to implement but could have a story about how it could be changed later. Even this is probably quite hard enough for a student project, since the interface really should assume the communication is asynchronous.
In any case, at some point the rubber will meet the road and you will have to read and/or write to the Cache database. And at that point, ODBC is available, and sounds like it would be a good choice for you. There are other methods to connect to Cache but ODBC is widely used (and therefore probably more reliable) and doesn't require you to learn Cache Object Script, which would be a lot of extra work for your situation.
There are many ways to achieve this - the best way to learn about this is to read "Enterprise Integration Patterns".
I wouldn't recommend writing directly to each other's database - it is a fragile way of gluing apps together, because a change in one schema requires you to change the other app at the exact same time. You have to deal with exotic failure modes - one database may be down for backups, which means you can't write the changes from the other database to it.
Read the book for alternatives!
I would like to set up a Drupal site for some of our customers to access their info externally to us. I have decided to implement this in Drupal to take full effect of all it has to offer. However our current system is in mssql which is not really supported by Drupal and not even really supported by PHP anymore.
So my question is how should I link the two databases (eg get info into Drupal for modules etc).
Move existing system to MySQL for easy integration (not likely at the moment)
Simply provide IFrames to pull in the info I require as pages
Get PDO MSSQL working on machine I've installed Drupal and make my own connection in Drupal module when I need it. (is this frowned upon? I may want to move machines)
Create an API for our main system to get the information out it requires. Set of URLs that return JSON
The easiest is probably 3 but I think I may live to regret that since MSSQL support is being rolled back and it seems like a bit of a hack.
I think I will go with 4 but was wondering whether people feel this is a good plan. Is it realistic from a performance point of view? Can anyone suggest a good API framework / route to go down?
The Forena module can be used to query (not update) all sorts of databases, such as a MS SQL database, and to establish database connections to the external databases. And it comes with various hooks to use Forena from within another module.
For more details about Forena, 2 types of documentation are available:
Community documentation.
Documentation that comes with Forena, which you can access right after install and enable of the module. Checkout the demo site for an online example of the current:
Forena documentation - use the link 'Reporting documentation' or visit relative link /reports/help.
Forena samples - use the link 'Reporting samples' or visit relative link /reports/samples (these samples are fully functional, so make sure to experiment a bit with it, such as the drill downs available on the SVG Graph sample).
The newest 7.x-4.x version also includes an amazing (I think) UI for either creating your reports (the WYSIWYG report editor) and/or for creating your SQL queries (the Query Builder).
Here are some variations of the MS SQL database part:
Using a SQLite instead of MS SQL database: the Forena samples actually get shipped including a (Tiny) SQLite database. Go check it out in the demo site: the data shown there are data contained in the sampledb, which is in SQLite format.
Forena comes with a full suite of Supported database connections ... such as MySQL, Oracle, Postgress or any PDO compliant variation.
Enough reasons for considering giving Forena a try? While doing so, use it's issue queue for any type of support/docu requests you may have.
Be aware: I'm a co-maintainer of Forena.
This doesn't really answer your actual question, but you might want to check out https://drupal.stackexchange.com/questions/1631/mssql-or-sql-server-wrapper-for-custom-module.
Not sure what you mean with " MSSQL support is being rolled back", but Microsoft created a PDO driver recently and a main reason for that was Drupal 7.
I'm writing a CMS application in PHP and one of the requirements is that it must be able to interface with the customer's Exchange server. I've written up this functionality a few times before and have always used WebDAV to do it, but now I'm leaning away from that.
I will be running the site on IIS OR Apache (no preference) on Windows server 2008. A few things I would need to do include adding contacts to a given user's address book, sending emails as a given user and running reports on contacts for a user.
All of this is pretty easy to do with WebDAV, but if there is a better way that doesn't require any functionality that is likely to be deprecated any time soon.
Any ideas?
Update:
Justin, I love the idea of using com objects, I just worry about maintaining a 3rd product to make everything work...
John, I can write a web service in C# to interface with for these functions and access it with my PHP app, but it's also a little bit out of the way.
So far, I'm not 100% convinced that either of these is better than WebDAV...
Can anyone show me where I'm being silly?
Update as of 2020:
Over a decade since this question and things have moved on. Microsft now has a Rest API that will allow you to easily access this data.
Original Answer
I have not used PHP to do this but have experience in using C# to achieve the same thing.
The Outlook API is a way of automating Outlook rather than connecting to Exchange directly. I have previously taken this approach in a C# application and it does work although can be buggy.
If you wish to connect directly to the Exchange server you will need to research extended MAPI.
In the past I used this wrapper MAPIEx: Extended MAPI Wrapper.
It is a C# project but I believe you can use some .NET code on a PHP5 Windows server. Alternatively it has a C++ core DLL that you may be a able to use. I have found it to be very good and there are some good example applications.
Sorry for the delay no current way to keep track of posts yet.
I do agree adding more layer on to your application and relying on 3rd party code can be scary (and rightfully so.)
Today I read another interesting post tagged up as MAPI that is on a different subject. The key thing here though is that it has linked to this important MS article. I have been unaware of the issues until now on using managed code to interface to MAPI although the C++ code in the component should be unaffected by this error as it is unmanaged.
This blog entry also suggests other ways to connect to MAPI/Exchange server. In this case due to these new facts http://us3.php.net/imap may be the answer as suggested by the other user.
Is your customer using Exchange 2007? If so, I'd have a look at Exchange Web Services. If not, as hairy as it can be, I think WebDAV is your best bet.
Personally I don't like using the Outlook.Application COM object route, as its security prompts ("An application is attempting to access your contacts. Allow this?", etc.) can cause problems on a server. I also think it would be difficult to accomplish your impersonation-like tasks using Outlook, such as sending mail as a given user.
I have released an open-source MIT licensed library that allows you to do some basic operations in PHP using Exchange Web Services.
Exchange Web Services for PHP
I have only tested it on Linux but I don't see any reason why it wouldn't work on a Windows installation of PHP as well.
I can't recommend Dmitry Streblechenko's Redemption Data Objects library highly enough. It's a COM component that provides a sane API to Extended MAPI and is a joy to use. The Exchange API goalposts move from one release to the next: “Use the M: drive! No, use WebDAV! No, use ExOLEDB!… No, use Web Services!” with the only constant being good old MAPI.
I'm not a PHP dev but Google says that PHP 5+ can instantiate COM components. If you can install Outlook on a box you could write a PHP web service around the COM component to handle the requests you need.
$outlook = COM("Outlook.Application")
Outlook API referance
I would recommend using "PHP Exchange Web Services" or short php-ews.
Fair amount of documentation under the wiki, helped me a lot.
This Zarafa PHP MAPI extension looks like it could work.
I would look into IMAP
IMAP, POP3 and NNTP
https://github.com/Garethp/php-ews
It was last updated 3 months ago so it is maintained