31 lines
2.2 KiB
Java
31 lines
2.2 KiB
Java
import java.io.FileInputStream;
|
|
import java.sql.*;
|
|
import java.util.Properties;
|
|
public class G3SoftCheck {
|
|
public static void main(String[] args) throws Exception {
|
|
Properties props = new Properties();
|
|
try (FileInputStream in = new FileInputStream(args[0])) { props.load(in); }
|
|
try (Connection conn = DriverManager.getConnection(props.getProperty("url"), props.getProperty("username"), props.getProperty("password"))) {
|
|
System.out.println("== objects mentioning g3soft / session_context ==");
|
|
try (Statement st = conn.createStatement(); ResultSet rs = st.executeQuery(
|
|
"SELECT o.type_desc, OBJECT_SCHEMA_NAME(o.object_id) AS sch, o.name, m.definition " +
|
|
"FROM sys.sql_modules m JOIN sys.objects o ON o.object_id = m.object_id " +
|
|
"WHERE m.definition LIKE '%g3soft%' OR m.definition LIKE '%session_context%' OR m.definition LIKE '%allow_g3soft%'")) {
|
|
boolean any = false;
|
|
while (rs.next()) { any = true; System.out.printf(" %-20s %s.%s%n def: %s%n%n", rs.getString("type_desc"), rs.getString("sch"), rs.getString("name"), rs.getString("definition")); }
|
|
if (!any) System.out.println(" (none)");
|
|
}
|
|
System.out.println("== views / security policies on b_user ==");
|
|
try (Statement st = conn.createStatement(); ResultSet rs = st.executeQuery(
|
|
"SELECT o.type_desc, OBJECT_SCHEMA_NAME(o.object_id) AS sch, o.name FROM sys.objects o " +
|
|
"WHERE o.name LIKE '%b_user%' OR o.name LIKE '%g3soft%' OR o.type = 'S' ORDER BY o.type, o.name")) {
|
|
while (rs.next()) System.out.printf(" %-20s %s.%s%n", rs.getString("type_desc"), rs.getString("sch"), rs.getString("name"));
|
|
}
|
|
System.out.println("== b_user current data ==");
|
|
try (Statement st = conn.createStatement(); ResultSet rs = st.executeQuery("SELECT b_id, b_account, b_canuse FROM b_user")) {
|
|
while (rs.next()) System.out.printf(" b_id=%s b_account=%s b_canuse=%s%n", rs.getString("b_id"), rs.getString("b_account"), rs.getString("b_canuse"));
|
|
}
|
|
}
|
|
}
|
|
}
|