Showing posts with label english. Show all posts
Showing posts with label english. Show all posts

Monday, March 26, 2012

How to connect to a remote database ?

Hello,

First, sorry for my bad English.

Here is my problem:

BoxA: XPpro + Apache + php (using php_mssql.php)+ ADOdb + MS SQL Server
+ My_Prog (using local MS SQL PUBS database)

BoxB: NT4 + Apache + php (using php_mssql.php)+ ADOdb + My_Prog (using
remote BoxA PUBS database)

BoxC: W2K

My_Prog uses:
$serveur = '10.0.0.1'; BoxA's IP address
$admin_nom = 'sa';
$admin_mdp = '';
$base = 'PUBS';

$conn = &ADONewConnection($sgbd);
$conn->debug = true;
$a = $conn->Connect ($serveur,$admin_nom,$admin_mdp,$base);

From BoxC, using IE, connecting to:
- BoxA My_Prog : I access PUBS, that's OK
- BoxB My_prog : "Warning: mssql_connect(): message: Echec de la
connexion de l'utilisateur 'sa'. Raison : Non associ une connexion
scurise SQL Server. (severity 14) in ...\adodb-mssql.inc.php on line
438." (I prefer to report the "French" message)

Anyone knows about ?

Thanks in advance,
EricEricP <eric.piquot@.wanadoo.fr> wrote in message news:<bvqrdf$6ri$1@.news-reader3.wanadoo.fr>...
> Hello,
> First, sorry for my bad English.
> Here is my problem:
> BoxA: XPpro + Apache + php (using php_mssql.php)+ ADOdb + MS SQL Server
> + My_Prog (using local MS SQL PUBS database)
> BoxB: NT4 + Apache + php (using php_mssql.php)+ ADOdb + My_Prog (using
> remote BoxA PUBS database)
> BoxC: W2K
> My_Prog uses:
> $serveur = '10.0.0.1'; BoxA's IP address
> $admin_nom = 'sa';
> $admin_mdp = '';
> $base = 'PUBS';
> $conn = &ADONewConnection($sgbd);
> $conn->debug = true;
> $a = $conn->Connect ($serveur,$admin_nom,$admin_mdp,$base);
>
> From BoxC, using IE, connecting to:
> - BoxA My_Prog : I access PUBS, that's OK
> - BoxB My_prog : "Warning: mssql_connect(): message: Echec de la
> connexion de l'utilisateur 'sa'. Raison : Non associ une connexion
> scurise SQL Server. (severity 14) in ...\adodb-mssql.inc.php on line
> 438." (I prefer to report the "French" message)
> Anyone knows about ?
> Thanks in advance,
> Eric

The error message suggests that MSSQL is configured to accept only
Windows logins. I don't know anything about PHP, but is it possible
that your connection string is somehow being ignored, and PHP is
making a trusted connection instead of using the sa login and
password? If Apache on BoxA is running as a local administrator
account, for example, then by default it would be able to connect
using a trusted connection. But Apache on BoxB connecting to MSSQL on
BoxA would be running under a different account, and so could not
connect.

But that's more or less a guess - if it doesn't help, you may want to
post some extra information. MSSQL version, authentication mode
(Windows or Mixed), service accounts used by Apache etc. You might
also want to use sp_who to verify that when BoxA connects, it is
connecting as sa, and not as some other (perhaps Windows) account.

Simonsql

Sunday, February 19, 2012

how to CHECK_POLICY = OFF

sorry for my bad english - i am working with some piece of code in SMO i do not understand well
(and rather had no time to understand it well) - this cpp-winapi-smo code was a part of instalator used to install
MSDE on client computer - It restore database from .backup file - and then configure dtabase, particulary
create few logins on restored database. -- I try to only change MSDE instalation on sqlex2k5 instalation
and encounter a problem mentioned in internet also - mainly - this code (i put here a fragmnt)

//create logins
Log(" Creating logins...");
debuglog(117,"try");
try
{
_LoginPtr pL;
if (SUCCEEDED(pL.CreateInstance("SQLDMO.Login")))
{
pL->Name = "flogin";
debuglog(118,"pL->Type = SQLDMOLogin_Standard;");
pL->Type = SQLDMOLogin_Standard;
pL->Database = m_sDatabase.AllocSysString();

try {
Log(" TTX ");

pSrv->GetLogins()->Add(pL); }

// <--

catch (_com_error err) {
Log("|| Exception during create flogin login");
Log("|| ErrorMessage: " + CString(err.ErrorMessage()));
debuglog(119,"CString sDesc = CW2A(err.Description());");
CString sDesc = CW2A(err.Description());
Log("|| ErrorDescription: " + sDesc);
(*dwExitCode) = err.WCode();
(*sErrorDescription) = sDesc;
}
pSrv->GetLogins()->Item("flogin")->SetPassword("", "jpnzpkzcnobwso");
pSrv->GetServerRoles()->Item("dbcreator")->AddMember("flogin");
Log(" Created 'flogin' login");
debuglog(120,"");
}
else
{
Log(" Creating 'flogin' login FAILED");
}

cannot create login becouse of CHECK_POLICY change in sql2k5 (as far as I know)
As far as I read I should execute from this kode sql line similiar to this "CREATE LOGIN bob WITH PASSWORD = 'password', CHECK_EXPIRATION = OFF, CHECK_POLICY = OFF" or do such thing in some SMO way
if possible but had no special idea how to do this one (sql) or the second (SMO)

MAybe someone could help me a bit with this.
Kenobi

There is a boolean property on the Login object called PasswordPolicyEnforced() which you'll want to set to false before creating the login.

That should solve your problem.

how to CHECK_POLICY = OFF

sorry for my bad english - i am working with some piece of code in SMO i do not understand well
(and rather had no time to understand it well) - this cpp-winapi-smo code was a part of instalator used to install
MSDE on client computer - It restore database from .backup file - and then configure dtabase, particulary
create few logins on restored database. -- I try to only change MSDE instalation on sqlex2k5 instalation
and encounter a problem mentioned in internet also - mainly - this code (i put here a fragmnt)

//create logins
Log(" Creating logins...");
debuglog(117,"try");
try
{
_LoginPtr pL;
if (SUCCEEDED(pL.CreateInstance("SQLDMO.Login")))
{
pL->Name = "flogin";
debuglog(118,"pL->Type = SQLDMOLogin_Standard;");
pL->Type = SQLDMOLogin_Standard;
pL->Database = m_sDatabase.AllocSysString();

try {
Log(" TTX ");

pSrv->GetLogins()->Add(pL); }

// <--

catch (_com_error err) {
Log("|| Exception during create flogin login");
Log("|| ErrorMessage: " + CString(err.ErrorMessage()));
debuglog(119,"CString sDesc = CW2A(err.Description());");
CString sDesc = CW2A(err.Description());
Log("|| ErrorDescription: " + sDesc);
(*dwExitCode) = err.WCode();
(*sErrorDescription) = sDesc;
}
pSrv->GetLogins()->Item("flogin")->SetPassword("", "jpnzpkzcnobwso");
pSrv->GetServerRoles()->Item("dbcreator")->AddMember("flogin");
Log(" Created 'flogin' login");
debuglog(120,"");
}
else
{
Log(" Creating 'flogin' login FAILED");
}

cannot create login becouse of CHECK_POLICY change in sql2k5 (as far as I know)
As far as I read I should execute from this kode sql line similiar to this "CREATE LOGIN bob WITH PASSWORD = 'password', CHECK_EXPIRATION = OFF, CHECK_POLICY = OFF" or do such thing in some SMO way
if possible but had no special idea how to do this one (sql) or the second (SMO)

MAybe someone could help me a bit with this.
Kenobi

There is a boolean property on the Login object called PasswordPolicyEnforced() which you'll want to set to false before creating the login.

That should solve your problem.