Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Running as a service and xp_cmdshell

3 posts in General Discussion Last posting was on 2010-09-15 14:34:03.0Z
Oyvind Eriksen Posted on 2010-09-15 08:10:31.0Z
From: Oyvind Eriksen <oyvind@eriksen.no>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.9) Gecko/20100825 Thunderbird/3.1.3
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Running as a service and xp_cmdshell
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4c907f77@forums-1-dub>
Date: 15 Sep 2010 01:10:31 -0700
X-Trace: forums-1-dub 1284538231 10.22.241.152 (15 Sep 2010 01:10:31 -0700)
X-Original-Trace: 15 Sep 2010 01:10:31 -0700, vip152.sybase.com
Lines: 10
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:8088
Article PK: 7114

I'm trying to run a SQL Anywhere 11 database as a Windows service.
The service is running under a specified user, not local system.
But when executing xp_cmdshell to start an external tool it is started
as the SYSTEM account, not the user which the service is running as.
If I start the database manual, not as a service, this is not an issue.
The system is running Windows Server 2008 R2 x64.
Is there a way around this problem? Is it a "bug" with SQL Anywhere 11?

With regards,
Oyvind Eriksen


John Smirnios [Sybase] Posted on 2010-09-15 13:27:56.0Z
From: "John Smirnios [Sybase]" <smirnios_at_sybase.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.9) Gecko/20100825 Thunderbird/3.1.3
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: Running as a service and xp_cmdshell
References: <4c907f77@forums-1-dub>
In-Reply-To: <4c907f77@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4c90c9dc$1@forums-1-dub>
Date: 15 Sep 2010 06:27:56 -0700
X-Trace: forums-1-dub 1284557276 10.22.241.152 (15 Sep 2010 06:27:56 -0700)
X-Original-Trace: 15 Sep 2010 06:27:56 -0700, vip152.sybase.com
Lines: 31
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:8089
Article PK: 7108

How are you determining the current user? I just tried it on Windows 7
x64 with the following and it seems to work:

call xp_cmdshell( 'whoami >d:\\tmp\\who.txt' )

who.txt:
sybase\smirnios

When I run as the local system account, I get "nt authority\system".

-john.

John Smirnios
Senior Staff Software Developer
iAnywhere Solutions Engineering

Whitepapers, TechDocs, bug fixes are all available through the iAnywhere
Developer Community at http://www.ianywhere.com/developer

On 9/15/2010 4:10 AM, Oyvind Eriksen wrote:
> I'm trying to run a SQL Anywhere 11 database as a Windows service.
> The service is running under a specified user, not local system.
> But when executing xp_cmdshell to start an external tool it is started
> as the SYSTEM account, not the user which the service is running as.
> If I start the database manual, not as a service, this is not an issue.
> The system is running Windows Server 2008 R2 x64.
> Is there a way around this problem? Is it a "bug" with SQL Anywhere 11?
>
> With regards,
> Oyvind Eriksen


Oyvind Eriksen Posted on 2010-09-15 14:34:03.0Z
From: Oyvind Eriksen <oyvind@eriksen.cn>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.9) Gecko/20100825 Thunderbird/3.1.3
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: Running as a service and xp_cmdshell
References: <4c907f77@forums-1-dub> <4c90c9dc$1@forums-1-dub>
In-Reply-To: <4c90c9dc$1@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4c90d95b@forums-1-dub>
Date: 15 Sep 2010 07:34:03 -0700
X-Trace: forums-1-dub 1284561243 10.22.241.152 (15 Sep 2010 07:34:03 -0700)
X-Original-Trace: 15 Sep 2010 07:34:03 -0700, vip152.sybase.com
Lines: 49
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:8090
Article PK: 7109

I checked with Taskmanager.
But I stand corrected.
I tried again now and xp_cmdshell was executed as the same user.
I don't understand, I'm sure that I checked and double checked that I
did everything correct the last time - but obviously not.

The external tool still doesn't work when running from a service though.
What it does is print out reports. I'm guessing that printing from a
service ain't allowed - or something like that. But that's not Sybase fault.

Sorry for troubling you.
Thank you for your help!

With regards,
Oyvind Eriksen

On 15.09.2010 15:27, John Smirnios [Sybase] wrote:
> How are you determining the current user? I just tried it on Windows 7
> x64 with the following and it seems to work:
>
> call xp_cmdshell( 'whoami >d:\\tmp\\who.txt' )
>
> who.txt:
> sybase\smirnios
>
> When I run as the local system account, I get "nt authority\system".
>
> -john.
>
> John Smirnios
> Senior Staff Software Developer
> iAnywhere Solutions Engineering
>
> Whitepapers, TechDocs, bug fixes are all available through the iAnywhere
> Developer Community at http://www.ianywhere.com/developer
>
>
> On 9/15/2010 4:10 AM, Oyvind Eriksen wrote:
>> I'm trying to run a SQL Anywhere 11 database as a Windows service.
>> The service is running under a specified user, not local system.
>> But when executing xp_cmdshell to start an external tool it is started
>> as the SYSTEM account, not the user which the service is running as.
>> If I start the database manual, not as a service, this is not an issue.
>> The system is running Windows Server 2008 R2 x64.
>> Is there a way around this problem? Is it a "bug" with SQL Anywhere 11?
>>
>> With regards,
>> Oyvind Eriksen