[mapserver-users] OGR ODBC Layer with Password
Brent Fraser
bfraser at geoanalytic.com
Tue Dec 17 15:13:21 PST 2013
Donald,
It's kind of a work-around, but a few years ago (mapserv v5.2.1) I
used the following method to connect to a database via ODBC:
CONNECTIONTYPE OGR
CONNECTION "<OGRVRTDataSource>
<OGRVRTLayer name='myTable'>
<SrcDataSource>ODBC:myUser/myPassword at myDSN,myTable</SrcDataSource>
<SrcSQL>
SELECT Longitude, Latitude, IDFROM myTable
</SrcSQL>
<FID>ID</FID>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>NAD83</LayerSRS>
<GeometryField encoding='PointFromColumns' y='Latitude'
x='Longitude'/>
</OGRVRTLayer>
</OGRVRTDataSource>"
PROCESSING "CLOSE_CONNECTION=DEFER"
DATA "myTable"
Best Regards,
Brent Fraser
On 12/17/2013 1:41 PM, Donald Kerr wrote:
> Jeff,
>
> Same password error, I'm afraid. It's as if MapServer is not passing the
> username/password combination.
>
> Many thanks.
>
> Regards,
>
> Donald
>
> -----Original Message-----
> From: mapserver-users-bounces at lists.osgeo.org
> [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Jeff McKenna
> Sent: 17 December 2013 20:36
> To: mapserver-users at lists.osgeo.org
> Subject: Re: [mapserver-users] OGR ODBC Layer with Password
>
> On 2013-12-17 4:14 PM, Donald Kerr wrote:
>> Any takers (see email below)? Help appreciated.
>>
>> Regards,
>>
>> Donald
>>
>> -----Original Message-----
>> From: Donald Kerr [mailto:donald.kerr at dkerr.co.uk]
>> Sent: 12 December 2013 16:45
>> To: 'Donald Kerr'
>> Subject: OGR ODBC Layer with Password
>>
>> Hi All,
>>
>> I have a layer that uses OGR to connect to an Microsoft Access
>> database via ODBC.
>>
>> CONNECTIONTYPE OGR
>> CONNECTION "ODBC: MyDNSName,MyTableName" # Requires GEOMETRY_COLUMNS
>> table (SPATIAL_REF_SYS optional) - Fails if DATA included in this map
>> file
>>
>> The above works on a database without password protection. When I add
>> a password to the database, I would expect to be able to connect using
>> the following line:
>>
>> CONNECTION "ODBC:Admin/MyPassword at MyDNSName,MyTableName" # Requires
>> GEOMETRY_COLUMNS table (SPATIAL_REF_SYS optional) - Fails if DATA
>> included in this map file
>>
>> But I get the following error in the log file:
>>
>> [Thu Dec 12 16:22:35 2013].484000 msDrawMap(): WMS/WFS set-up and
>> query, 0.000s [Thu Dec 12 16:22:35 2013].484000
>> msOGRFileOpen(ODBC:Admin/MyPassword at MyDSNName,MyTableName)...
>> [Thu Dec 12 16:22:35 2013].484000
>> OGROPen(ODBC:Admin/MyPassword at MyDSNName)
>> [Thu Dec 12 16:22:35 2013].515000 msOGRFileOpen(): OGR error. Open
>> failed for OGR connection in layer `MyLayerName'.
>> Unable to initialize ODBC connection to DSN for
>> Admin/MyPassword at MyDSNName, [Microsoft][ODBC Microsoft Access Driver]
>> Not a valid password
>>
>> The only difference is the username and password being included in the
>> connection string.
>>
>> If I run the following at the command line, all works well:
>>
>> C:\ >ogrinfo ODBC:Admin/MyPassword at MyDSNName,MyTableName
>> INFO: Open of `ODBC:Admin/MyPassword at MyDSNName,MyTableName'
>> using driver `ODBC' successful.
>> 1: MyTableName
>>
>> It would appear that the Username and Password are being ignored or
>> changed when used by MapServer since ogrinfo is working correctly and
>> opening the connection.
>>
>> Any ideas?
>>
>> Many thanks.
>>
>> Regards,
>>
>> Donald
>>
>>
> If this is all hosted on the same Windows machine, what happens if you
> leave out the user/pass? eg. ogrinfo ODBC:@DSN table
>
> -jeff
>
>
>
>
> --
> Jeff McKenna
> MapServer Consulting and Training Services http://www.gatewaygeomatics.com/
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 2014.0.4259 / Virus Database: 3658/6928 - Release Date: 12/17/13
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
More information about the MapServer-users
mailing list