I am trying to populate a drop down list in a form using an inline ipl script which connects to a remote database server. When I run the script on the command line as myself it works fine. When running through inline, the script is run as user
nt authority\system and the connection fails with the error pasted below.
My question is - Can I set the inline function to run ipl scripts as a different user, or is the another reason why this is not working?
The ipl script runs fine and returns to the inline call when I remove the db connection code. Any help would be greatly appreciated.
Part of my datacapture.cfg file that calls the ipl script:
<item name="Category" pathid="Category">
<label>Category</label>
<inline command="D:\iw-home\iw-perl\bin\iwperl.exe
\iw-home\custom\bin\templating\ipl\recipeListCategories.ipl" />
</item>
My perl script recipeListCategories.ipl:
use DBI;
$DSN = 'driver={SQL Server};SERVER=dbserver,1433;Network=DBMSSOCN;Database=database';
$username = 'username';
$password = 'password';
# Connect the database
$dbh = DBI->connect("DBI
DBC:$DSN", $username, $password) or die "$DBI::errstr\n";
my $select = $dbh->prepare("SELECT * FROM category;");
$select->execute();
my $output;
while(my @row=$select->fetchrow_array) {
$output .= qq~<option value="$row[0]" label="$row[1]" />~;
}
# Close connection
$dbh->disconnect;
print <<EOF;
<substitution>
<select>
$output
</select>
</substitution>
EOF
Returned when running perl script from command line:
<substitution>
<select>
<option value="1" label="test value one" /><option value="2" label="test value two" /><option value="3" label="test value three" />
</select>
</substitution>
Returned when running perl script through inline:
Root cause:
DBI connect('driver={SQL Server};SERVER=dbserver,1433;Network=DBMSSOCN;Database=database','username',...) failed: [Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]General network error. Check your network documentation. (SQL-08001)
[Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]ConnectionOpen (Connect()). (SQL-01000)(DBD: db_login/SQLConnect err=-1) at
\iw-home\custom\bin\templating\ipl\recipeListCategories.ipl line 46
[Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]General network error. Check your network documentation. (SQL-08001)
[Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]ConnectionOpen (Connect()). (SQL-01000)(DBD: db_login/SQLConnect err=-1)