I can connect to DB without using winAuth, but not ok if I using winAuth.
Here is the permission setting, I am using EFTG\eftg_app_svc
I cannot post image, but I believe I have correct permission setting.
And configured the SQL server can use window auth.
And here is my code:
HRESULT OpenDataSource()
{
HRESULT hr;
CDataSource db;
CDBPropSet dbinit(DBPROPSET_DBINIT);
if (m_DBCfg.GetWindowsAuthFlag())
{
dbinit.AddProperty(DBPROP_AUTH_INTEGRATED, OLESTR("SSPI"));
}
else
{
dbinit.AddProperty(DBPROP_AUTH_PASSWORD, OLESTR(""));
dbinit.AddProperty(DBPROP_AUTH_USERID, m_DBCfg.GetDatabaseUsername());
}
dbinit.AddProperty(DBPROP_INIT_CATALOG, m_DBCfg.GetDatabaseName());
dbinit.AddProperty(DBPROP_INIT_DATASOURCE, m_DBCfg.GetDatabaseServer());
dbinit.AddProperty(DBPROP_INIT_LCID, (long)1033);
dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4);
dbinit.AddProperty(DBPROP_INIT_OLEDBSERVICES, DBPROPVAL_OS_RESOURCEPOOLING);
hr = db.OpenWithServiceComponents(_T("SQLOLEDB.1"), &dbinit);
if (FAILED(hr))
return hr;
But DB eventlog: -> Login failed for user 'EFTG\eftg_app_svc'. [CLIENT: ] What's wrong???
Thanks very much!!
Aucun commentaire:
Enregistrer un commentaire