The "if(auto.integrated_security" statement looks for a property on the device to indicate if integrated security should be used. If it should be used, the difference is the connection string, the SQLUrl variable. It'll contain "integratedSecurity=true" if you're using Windows. It'll have user and pass if it's false (or if it doesn't exist).
However, the real problem is that there is no variable in your script called "auto.integrated_security". You intended for that to look in LM and find the property by that name, but you skipped it. You'd need to do something like this:
import org.xbill.DNS.*;
import groovy.sql.Sql;
def returnCode = 0;
def sql = null;
try {
dbname = hostProps.get("databasexyz")
hostname = hostProps.get('system.hostname');
integrated = hostProps.get('auto.integrated_security');
//Check for Integrated Security and then authenticate that way if it's available
if(integrated){ //just checks if the variable is true. It'll be null (false) if the hostProps.get statement above failed to find the property in LM
SQLUrl = "jdbc:sqlserver://${hostname};integratedSecurity=true;applicationIntent=ReadOnly;logintimeout=5";
} else {
user = hostProps.get("jdbc.mssql.user");
pass = hostProps.get("jdbc.mssql.pass");
SQLUrl = "jdbc:sqlserver://${hostname}:1433;user=${user};password=${pass}";
}
sql = Sql.newInstance(SQLUrl)
// Loop through every row returned by the query
sql.eachRow( 'SELECT * from blah blah blah')