为什么需要密码加密时连接ASE失败? [英] Why does the connection to ASE fail when password encryption is required?

查看:75
本文介绍了为什么需要密码加密时连接ASE失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何对从 PHP 到 Sybase ASE 的数据库服务器连接进行密码加密?

How can I password encrypt the database server connections from PHP to Sybase ASE?

net password encryption reqd = 1 时,PHP 与 ASE 的连接失败.

The PHP connection to ASE fails when net password encryption reqd = 1.

我们如何通过密码加密建立到 ASE 的 PHP DB 连接?有没有我们需要在客户端连接上设置的PHP关键字或参数?

How can we make a PHP DB connection to ASE with password encryption? Is there a PHP keyword or parameter that we need to set on the client side connection?

推荐答案

以下是解决此问题的解决方案,能够从具有 PHP 版本 5.3.6 的 Linux 64 位主机和来自 Sybase CTISQL 的 Sybase 驱动程序连接 <代码>Utility/15.7/P-EBF19975 ESD #3/DRV.15.7.0.3.当我们让它工作时,除此之外我们还需要让 Apache 工作,我希望 Sybase 支持能够帮助我们解决这个问题,就像他们在下面解决我们的问题一样.我把这个贴在这里是为了大家的利益.注意:AFAICT,这不是 Sybase 支持的解决方案.请自行承担风险.

Below is a solution to this problem in term of able to connect from a Linux 64 bit base machine with PHP version 5.3.6 and Sybase driver from Sybase CTISQL Utility/15.7/P-EBF19975 ESD #3/DRV.15.7.0.3. While we got this to work, we need to have Apache to work in addition to this, I am hoping Sybase support is able to help us with that as well as they have with solution below to our question. I am posting this here for everyone benefit. Note: AFAICT, this is not a supported solution by Sybase. Please use it as your own risk.

很少需要做这件事才能工作:

Few things need to happen for this to work:

  1. 我使用了最新的 Debian Stable 6.05 64 位压缩版
  2. 我已经安装了从 Sybase 下载的 ebf19977(带有开放客户端的开发工具包,是的,数字是关闭的,这不是错误,安装时您会看到)
  3. 从 php.net 网站下载 PHP 5.3.6 以从源代码编译.

步骤 1) 我认为应该很容易设置.确保您有 sudo 访问权限

Step 1) I am assume one should easily set this up. Make sure you have sudo access

步骤 2) 要安装开发工具包,您需要输入 setup.bin 文件所在位置的完整路径,就像输入 sudo/home/btran/ebf19977/setup.bin 一样,这将开始设置,几乎按照那里的说明安装 OpenClient 及其相关工具.确保已安装 Open Client 和 PHP 库.

Step 2) To install the developer kit you need to type the whole path to where the setup.bin file is locate like so type in sudo /home/btran/ebf19977/setup.bin , this will start the setup, pretty much follow instructions there to to install OpenClient and its associate tools. Make sure that Open Client, and PHP library are install.

完成安装后,还有一些其他步骤要做:

Once you done the install there are a few other steps to do:

通过执行/opt/sybase 根目录中的 SYBASE.sh 来设置所有 Sybase 环境变量

Set all Sybase environments variables by executing the SYBASE.sh in the root directory at /opt/sybase

sudo cat /opt/sybase/SYBASE.sh >> /etc/profile , if necessary source /etc/profile

这将设置大部分变量,但您需要添加一些不存在的变量:

This will set most of the variables, but you need to add a couple variable that is not there:

    PHPRC=/opt/sybase/OCS-15_0/config
    LD_LIBRARY_PATH=/opt/sybase/OCS-15_0/php/php536_64/lib:/opt/sybase/OCS-15_0/lib

您的/ect/profile 应如下所示:

Your /ect/profile should look something like this:

    # ------------------------------------
    #    Sybase Product Environment variables
    # ------------------------------------
    SYBASE="/opt/sybase"
    export SYBASE
    SYBASE_OCS="OCS-15_0"
    export SYBASE_OCS
    INCLUDE="/opt/sybase/OCS-15_0/include":$INCLUDE
    export INCLUDE
    LIB="/opt/sybase/OCS-15_0/lib":$LIB
    export LIB
    PATH="/opt/sybase/OCS-15_0/bin":$PATH
    export PATH
    LD_LIBRARY_PATH="/opt/sybase/OCS-15_0/php/php536_64/lib:/opt/sybase/OCS-15_0/lib:/opt/sybase/OCS-15_0/lib3p64:/opt/sybase/OCS-15_0/lib3p":$LD_LIBRARY_PATH
    export LD_LIBRARY_PATH

    PHPRC="/opt/sybase/OCS-15_0/config"
    export PHPRC

    JAVA_HOME="/opt/sybase/jre32"
    export JAVA_HOME

    RIBO_HOME="/opt/sybase/jutils-3_0/ribo"
    export RIBO_HOME
    # ------------------------------------

然后,您还需要对位于根目录/opt/sybase 的interfaces 文件进行修改,使其看起来像这样,请不要使用它,请使用您的信息:

Then, you will also need to made modification to the interfaces file located at root directory /opt/sybase to look something like this, please do not use this, use your info:

    dev
        master tcp ether dev.company.com 4425
        query tcp ether dev.company.com 4425

    prod
        master tcp ether prod.company.com 4425
        query tcp ether prod.company.com 4425

    ribo
        master tcp ether testhost.company.com 5005
        query tcp ether testhost.company.com 5005

您还需要修改 ocs.cfg 以使 PHP 正确启动,它位于文件夹 /opt/sybase/OCS-15_0/config 中,如下所示:

You will also need to made modification to the ocs.cfg to get PHP to initiated correctly, this located in the folder /opt/sybase/OCS-15_0/config to look like this:

    ;;;;;;;;;;;
    ; This is the default external configuration definition file. Feel free
    ; to add your own customizations.
    ;
    [DEFAULT]
    ; This is the default section loaded by applications that use
    CS_SEC_ENCRYPTION = CS_TRUE
    [ANSI_ESQL]
    ; This section defines configuration which an ANSI conforming
    CS_CAP_RESPONSE = CS_RES_NOSTRIPBLANKS
    CS_EXTRA_INF = CS_TRUE
    CS_ANSI_BINDS = CS_TRUE
    CS_OPT_ANSINULL = CS_TRUE
    CS_OPT_ANSIPERM = CS_TRUE
    CS_OPT_STR_RTRUNC = CS_TRUE
    CS_OPT_ARITHABORT = CS_FALSE
    CS_OPT_TRUNCIGNORE = CS_TRUE
    CS_OPT_ARITHIGNORE = CS_FALSE
    CS_OPT_ISOLATION = CS_OPT_LEVEL3
    CS_OPT_CHAINXACTS = CS_TRUE
    CS_OPT_CURCLOSEONXACT = CS_TRUE
    CS_OPT_QUOTED_IDENT = CS_TRUE
    ; End of default sections

    [isql]
    CS_SEC_ENCRYPTION = CS_TRUE

    [PHP]
    CS_SEC_ENCRYPTION = CS_TRUE

    ; This is a sample section showing how you might alter configuration
    ; properties for you Embedded SQL application.
    [SAMPLE_ESQL]
    ; use most of the ANSI properties defined above
    include = ANSI_ESQL
    ; but override some default properties
    CS_OPT_CHAINXACTS = CS_FALSE ; run in autocommit mode
    ;;;;;;;;;

注意:非常重要的是检查同一目录中是否存在 php.ini 文件/opt/sybase/OCS-15_0/config(这个指向扩展文件,看环境变量 LD_LIBRARY_PATH="/opt/sybase/OCS-15_0/php/php536_64/lib)

Note: Very Critical to check for the existence of the php.ini file in the same directory as well /opt/sybase/OCS-15_0/config (this pointing the exention file, look at the environment variable LD_LIBRARY_PATH="/opt/sybase/OCS-15_0/php/php536_64/lib)

你的 php.ini 应该是这样的:

you php.ini should read like this:

    extension=/opt/sybase/OCS-15_0/php/php536_64/lib/sybaseasephp.so

步骤 3) 从源代码编译 PHP,再次调用 64 位的 Sybase.

Step 3) compile PHP from source, again Sybase call for 64 bit.

我将源代码下载到 /opt/php-5.3.6 以便在大多数 Linux 应用程序安装的地方进行持久化.

I down load the source to /opt/php-5.3.6 for persistent with where most app install for Linux.

    cd to /opt/php-5.3.6 

    ./configure  

非常重要要注意,这是我们遇到障碍的地方,如果我选择任何其他配置选项而不是默认的 ./configure,PHP 将无法加载并出现以下错误:

VERY IMPORTANT to note, this is where we ran into a snag, if I choose any other configure option and not default ./configure, PHP will fail to load with error below:

btran@sls-baonix:/opt/php-5.3.6$ php ~/test-dev.php
PHP Warning:  PHP Startup: Unable to load dynamic library
'/opt/sybase/OCS-15_0/php/php536_64/lib/sybaseasephp.so' -
/opt/sybase/OCS-15_0/php/php536_64/lib/sybaseasephp.so: undefined
symbol: executor_globals in Unknown on line 0

Fatal error: Call to undefined function sybase_connect() in
/home/btran/test-dev.php on line 10
]

我们需要其他选项的原因是我们还需要它与 Apache 一起工作.我们现在让它与 PHP 一起工作,但是我们需要能够从网站启动 PHP,所以依赖项是 PHP 除了支持 Sybase 之外,它还需要支持 Apache.如果有任何 PHP 专家对此有解决方案,请加入并帮助我们.

Reason we need other options is we need it also to work with Apache. We got it now to work with PHP, but we need to be able to initiate PHP from website so the dependencies is that PHP beside support Sybase, it also need to support Apache. If any PHP expert out there has solution to this please jump in and help us out.

这篇关于为什么需要密码加密时连接ASE失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆