Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Running dbiproxy as a service on Windows

by RandomMonkey (Initiate)
on Jul 01, 2010 at 23:52 UTC ( [id://847650]=perlquestion: print w/replies, xml ) Need Help??

RandomMonkey has asked for the wisdom of the Perl Monks concerning the following question:

I have been trying to get dbiproxy to run as a service on one of our PC's so we can access Windows resources from Unix. I have had no problem getting it to run and work great, if I run it manually from a shell. I want to run it as a service so it will come up when we reboot and so it doesn't block the PC by consuming the login.

I have spent a lot of time getting it to run as a service. I eventually have been successful running it as a service using Windows srvany.exe (Windows doc) and some registry updates on Windows XP SP3. I am pretty sure it is actually running because I see my port listening when running netstat -a and the fact that it appears to be an error message from dbiproxy (see code section below).

For some reason, on the dbiproxy box, if I run dbiproxy from a shell and leave it running, it works great. But when run as a service I get this message (starred specifics in message).

DBI connect('hostname=*******;port=36502;dsn=dbi:ODBC:driver=Microsoft + Access Driver (*.mdb, *.accdb);dbq=*******','',...) failed: Cannot l +og in to DBI::ProxyServer: Refused by server: User is not permitted +to connect. at /*******/usr/local/lib/perl5/site_perl/5.10.0/RPC/PlCl +ient.pm line 82. at ./testDbiProxy.pl line 9

I can run both the service and the command line on two different ports at the same time. The one from the command line has no problems, but my service gives this error. I run the exact same client code with the exception of the port number.

One co-worker suggested that maybe my service was running as SYSTEM. I reconfigured the service to run as my userid (and separately as a application user id we use internally here), but I get the same error.

Is there something else in the "Windows service sandbox" that I don't understand and is causing this error?

Any ideas how to approach solving this problem?

Is there any better way to try doing what I am trying to do?

Here is the content of the *.bat file I created to start dbiproxy from the command line and from srvany (with varying ports for testing)

C:\cygwin\bin\perl C:\cygwin\usr\local\bin\dbiproxy --localport 36503 --logfile C:\cygwin\home\*******\dbiproxy.log --mode fork --debug

BTW, I did search google and monks for this same error. No solid leads from google. Found literally this exact problem asked here with no answers in 2005. Starting dbiproxy as a Win32 Service

Replies are listed 'Best First'.
Re: Running dbiproxy as a service on Windows
by BrowserUk (Patriarch) on Jul 02, 2010 at 00:36 UTC

    Is the DSN you are using set up as a User DSN or a System DSN? (Hint: Services cannot access User DSNs)

    Have you checked the Event Viewer for further info?

Re: Running dbiproxy as a service on Windows
by NetWallah (Canon) on Jul 02, 2010 at 04:59 UTC
    I think the "service" version is probably reading a different "Configuration file" to determine authorized clients (IP addresses) and/or users.

    The error message seems to come from this code in RPC::PIServer:

    if (!($result = $self->AcceptUser($user, $password))) { $comm->Write($socket, [0, "User $user is not permitted to connect."]); return 0; }
    "AcceptUser" authenticates the username against a user list, which I presume comes from a config file.

    Sorry - no time to dig much deeper, but hopefully, this directs you toward solving this issue.

    Remember that the SERVICE sees different environment variables (in particular PATH) than running from a cmd shell.

         Syntactic sugar causes cancer of the semicolon.        --Alan Perlis

Re: Running dbiproxy as a service on Windows
by Anonymous Monk on Jul 02, 2010 at 00:11 UTC
    Is there something else in the "Windows service sandbox" that I don't understand and is causing this error?

    I think so because thats what the error says (your service probably needs DCOM/RPC ... dependencies, and relative perms)

    Any ideas how to approach solving this problem?

    Lots of reading of windows and ODBC documentation, sorry :)

Re: Running dbiproxy as a service on Windows
by RandomMonkey (Initiate) on Jul 07, 2010 at 19:48 UTC

    I wanted to update this thread and let everyone know I got dbiproxy running as a server. Or rather had it running all along.

    It turns out that when I set the user id in Windows Services, it doesn't take effect until a reboot. After a reboot it acted as the user I specified in the Services dialogs under "Log on". I think maybe the srvany.exe tool that Windows provides spawns off a child process to run the "whatever you specify" as a service. So changing the user only changed the master process. Rebooting causes it to be that user as soon as it starts up.

    Thanks for the responses.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://847650]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-03-28 22:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found