Skip to content

Commit e019258

Browse files
committed
Cope with incorrect trusted login
If the current user tries to connect to a server without a valid credential e.g. across domains without trust, give them a specific error message.
1 parent 5eaa294 commit e019258

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

sqlgrep/sqlgrep.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,21 @@ int main(int argc, char** argv)
239239
}
240240
catch (odbc_soci_error & e)
241241
{
242-
if(string(reinterpret_cast<char const*>(e.odbc_error_code())) == "28000" && e.native_error_code() == 18456)
242+
if(string(reinterpret_cast<char const*>(e.odbc_error_code())) == "28000")
243243
{
244-
write_error("The login credentials may be incorrect.");
245-
}
246-
else
247-
{
248-
write_error("DB error: "s + e.what());
244+
if (e.native_error_code() == 18452)
245+
{
246+
write_error("You attempted to connect with a trusted connection, but the current user is not trusted. Try a username and password.");
247+
return 2;
248+
}
249+
if(e.native_error_code() == 18456)
250+
{
251+
write_error("The login credentials may be incorrect.");
252+
return 2;
253+
}
249254
}
255+
256+
write_error("DB error: "s + e.what());
250257
return 1;
251258
}
252259
catch (soci_error& e)
@@ -262,6 +269,6 @@ int main(int argc, char** argv)
262269
catch (...)
263270
{
264271
write_error("Something went wrong.");
265-
return 2;
272+
return 3;
266273
}
267274
}

0 commit comments

Comments
 (0)