Friday, March 30, 2012

IUSR_ to run function, drop table..

Helo all,

i dont know if that is the right way, but i was wanted to make kind of sql profiler on a webpage :) and cool features would be to usa ajax to fire it async in some time secvence.. ok, ok, here goes my code and expla... i have sql2005 (express edition,, cose i think its so cool and for a lot of projects can be used for), attached startup procedure, whit>sp_procoption 'kreni_instanco_moja', startup, true,and kreni_insta... is like:

------
setANSI_NULLSON
setQUOTED_IDENTIFIERON
GO
ALTERPROCEDURE [dbo].[kreni_instanco_moja]
AS
BEGIN
exec kp.dbo.start_trace
END
------

ok and my start_trace is:

------
ALTERPROCEDURE [dbo].[start_trace]
AS
BEGIN
DECLARE
@.traceidnumINT,@.onBIT,@.file_pathNVARCHAR(50),@.maxsizebigint;
SET @.on= 1;SET @.maxsize=5;
SET @.file_path='O:\BU_DATABASE\'+convert(varchar,getdate(), 102);
EXEC sp_trace_create @.traceid= @.traceidnumOUTPUT, @.options= 2, @.tracefile= @.file_path, @.maxfilesize= @.maxsize, @.stoptime=null, @.filecount=0;
EXEC sp_trace_setevent 2, 12, 1, @.on-- ili 12 ili 13
EXEC sp_trace_setstatus 2, 1-- 1 = START, 0 = STOP
END
------

actual code that brings table and shows sql executed is:

------
use kp
droptable trace
select textdatainto tracefrom
fn_trace_gettable(N'O:\BU_DATABASE\'+convert(varchar,getdate(), 102)+'.trc',1)
select textdatafrom trace
go
------


and it works fine,, but when its fired from my local admin connection, and try that whit IUSR*?? not going... ok, i think that IUSR have to have privilage to open that O:\BU_DATABASE ... file, and to have priv to drop tabel and to fire that function..fn_trace_get ... ?? so, that is where i got stuck up... any help would be veryyyy apreciated... hey, we can put some kind of project if anybody is interested! :) to have admin page and to monitor sql code that is executed,,, and remotely

if i was not clear in some explaining, you can ask me and ill try better

thenx, kpendic

Yes, the connecting user needs all the privileges you stated (file, drop etc.), plus system wide ALTER TRACE permission.

|||

Yes Gunteman, and even ALTER TRC permission... but do you know how to achive this maybe??

thenx

sql

No comments:

Post a Comment