Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Friday, March 30, 2012

personal edition then move to enterprise

Hello,

Could i start work with personal edition then move all data to
enterprise edition ? i've to design and code on workgroup environment
then implement to windows server 2003. Do i just cut & paste data ?

TIA

PongYou can develop on Personal Ed then backup and restore to Enterprise or
you can develop TSQL scripts to build the database and load the data
from scratch.

Another option for development and testing is Developer Edition, which
MS prices at $50. Developer is functionally equivalent to Enterprise,
which means it comes without the constraints on capacity, features and
performance of Personal Ed.

--
David Portas
SQL Server MVP
--

Wednesday, March 28, 2012

Persisting Code (Repost)

I have created a SRS report with 6 columns. I would like every 3rd Row of
the report to have a silver background and white on the rest. When I run
the report the first time I get the desired result. Then, depending on the
number of rows the report returns, successive runs of the report will have
the silver row starting on 1, 2 or 3. My guess is that SRS is remembering
where the code left off and picks up from there on the successive runs.
I added the following code to my report:
Private Shared count As Integer = 0
Private Shared colors As String() = {"White","White","White","White","White","White","White","White","White","White","White","White","Silver","Silver","Silver","Silver","Silver","Silver"}
Public Function GetColor() As String
Dim c as string = colors(count Mod colors.Length)
count = count + 1
Return c
End Function
Then, on the background Color I have:
=Code.GetColor()
George F Grund IVWould removing the shared keyword achieve your desired results?
You could also try and reset the count by creating a function like
below and then calling from your page header.
public function ResetVariable() as string
count = 0
return ""
end function|||Well, I'll asumme that you are using a table with no groups. If so, what you
are trying to do is very simple and you don't that code. Select the detail
row, then in the background color porperty type something like this:
=IIF(RowCount("YourDataSet") mod 3 = 0, "#D3D3D3", "#FFFFFF")
D3D3D3 is the RBG code for Light Gray, and FFFFFF is for White
I hope this helpssql

Monday, March 26, 2012

Permissions with sp

Hi,
I programmed a Sp, which I gave permissions to some users to execute,
nevertheless, inside the code makes inserts and updates to tables where they
only have select permissions. So whenever they execute them a error message
is produced. How can i turnaround this. I want the sp to actually write in
some tables which they only have select permissions. Is there a solution.
Thanks
--
Carlos DiasHi,
Execute permission on the SP for that user should be fine to Insert or
Delete or Update.
GRANT EXEC ON SPNAME TO Username
Thanks
Hari
SQL Server MVP
"Carlos Dias" <CarlosDias@.discussions.microsoft.com> wrote in message
news:1801CAC0-5691-4146-B63C-7E2E99E87405@.microsoft.com...
> Hi,
> I programmed a Sp, which I gave permissions to some users to execute,
> nevertheless, inside the code makes inserts and updates to tables where
> they
> only have select permissions. So whenever they execute them a error
> message
> is produced. How can i turnaround this. I want the sp to actually write in
> some tables which they only have select permissions. Is there a solution.
> Thanks
> --
> Carlos Dias|||It would help us better assist you if you could include table DDL, and the
entire stored procedure code. Without this effort from you, we are just
playing guessing games.
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"Carlos Dias" <CarlosDias@.discussions.microsoft.com> wrote in message
news:1801CAC0-5691-4146-B63C-7E2E99E87405@.microsoft.com...
> Hi,
> I programmed a Sp, which I gave permissions to some users to execute,
> nevertheless, inside the code makes inserts and updates to tables where
> they
> only have select permissions. So whenever they execute them a error
> message
> is produced. How can i turnaround this. I want the sp to actually write in
> some tables which they only have select permissions. Is there a solution.
> Thanks
> --
> Carlos Dias|||Users do not need any permissions on tables used in a stored procedure as
long as:
1) all objects are owned by the same user (SQL 2000) or have same schema
owner (SQL 2005)
2) you do not use dynamic SQL
This behavior is known as ownership chaining. See the Books Online for more
information.
Hope this helps.
Dan Guzman
SQL Server MVP
"Carlos Dias" <CarlosDias@.discussions.microsoft.com> wrote in message
news:1801CAC0-5691-4146-B63C-7E2E99E87405@.microsoft.com...
> Hi,
> I programmed a Sp, which I gave permissions to some users to execute,
> nevertheless, inside the code makes inserts and updates to tables where
> they
> only have select permissions. So whenever they execute them a error
> message
> is produced. How can i turnaround this. I want the sp to actually write in
> some tables which they only have select permissions. Is there a solution.
> Thanks
> --
> Carlos Dias

Permissions to view code but not modify (Help)

Hello Everyone,
I am new to SQL 2005 and am trying to setup permissions for the vb .net
programmers.
I want them to be able to look at the stored procedure/view/functions code
but not be able to modify the code.
How can I accomplish this.
Thanks for all the help
Shabnam
Grant them VIEW DEFINTION permissions. Either at the server, database, schema or object level.
See ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/151b7a2e-ab97-42ba-baf0-6929c5334e29.htm
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Shabnam Gupta" <sgupta@.evcsolutions.com> wrote in message
news:ePR8IIhFGHA.3056@.TK2MSFTNGP09.phx.gbl...
> Hello Everyone,
> I am new to SQL 2005 and am trying to setup permissions for the vb .net programmers.
> I want them to be able to look at the stored procedure/view/functions code but not be able to
> modify the code.
> How can I accomplish this.
>
> Thanks for all the help
> Shabnam
>

Permissions to view code but not modify (Help)

Hello Everyone,
I am new to SQL 2005 and am trying to setup permissions for the vb .net
programmers.
I want them to be able to look at the stored procedure/view/functions code
but not be able to modify the code.
How can I accomplish this.
Thanks for all the help
ShabnamGrant them VIEW DEFINTION permissions. Either at the server, database, schema or object level.
See ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/151b7a2e-ab97-42ba-baf0-6929c5334e29.htm
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Shabnam Gupta" <sgupta@.evcsolutions.com> wrote in message
news:ePR8IIhFGHA.3056@.TK2MSFTNGP09.phx.gbl...
> Hello Everyone,
> I am new to SQL 2005 and am trying to setup permissions for the vb .net programmers.
> I want them to be able to look at the stored procedure/view/functions code but not be able to
> modify the code.
> How can I accomplish this.
>
> Thanks for all the help
> Shabnam
>sql

Permissions to view code but not modify (Help)

Hello Everyone,
I am new to SQL 2005 and am trying to setup permissions for the vb .net
programmers.
I want them to be able to look at the stored procedure/view/functions code
but not be able to modify the code.
How can I accomplish this.
Thanks for all the help
ShabnamGrant them VIEW DEFINTION permissions. Either at the server, database, schem
a or object level.
See ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/151b7a2e-ab97-42ba-baf0-
6929c5334e29.htm
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Shabnam Gupta" <sgupta@.evcsolutions.com> wrote in message
news:ePR8IIhFGHA.3056@.TK2MSFTNGP09.phx.gbl...
> Hello Everyone,
> I am new to SQL 2005 and am trying to setup permissions for the vb .net pr
ogrammers.
> I want them to be able to look at the stored procedure/view/functions code
but not be able to
> modify the code.
> How can I accomplish this.
>
> Thanks for all the help
> Shabnam
>

Permissions to run vb code

In one of my reports I’m using vb code that copies one file from a local disk to a server.

Like this:

Public Shared Function CopyFile(ByVal infile As String, ByVal outfile As String)

Dim fi As System.IO.FileInfo = New System.IO.FileInfo(infile)

fi.CopyTo(outfile, True)

End function

The report is executed using report services directly in a browser.

In the Visual Studio environment it works ok. In the browser I get an error. I’m sure it is a permissions problem.

Any pointers to set op permission for this rdl-file ?

/NHS

There is no way to elevate code permissions for a particular RDL.

Better way is to move this code into a separate assembly, grant permissions to that assembly and call it from the report.

Permissions to run vb code

In one of my reports I’m using vb code that copies one file from a local disk to a server.

Like this:

Public Shared Function CopyFile(ByVal infile As String, ByVal outfile As String)

Dim fi As System.IO.FileInfo = New System.IO.FileInfo(infile)

fi.CopyTo(outfile, True)

End function

The report is executed using report services directly in a browser.

In the Visual Studio environment it works ok. In the browser I get an error. I’m sure it is a permissions problem.

Any pointers to set op permission for this rdl-file ?

/NHS

There is no way to elevate code permissions for a particular RDL.

Better way is to move this code into a separate assembly, grant permissions to that assembly and call it from the report.

Wednesday, March 21, 2012

Permissions Problem using Dynamic SQL

Hi all!

I've got a problem where I have created a stored procedure (using MS SQL Server 2000) that does a temporary table creation:

Code Snippet

CREATE #tmpData ( [some_fields] )

and then it uses dynamic SQL to populate the data

Code Snippet

SELECT @.ExecStr =
'INSERT INTO #tmpData
SELECT * FROM tData
WHERE [some_condition]
ORDER BY ' + @.SortColumn /* input parm to the SP */
EXEC (@.ExecStr)

I get a permissions error 229 when I try to run this because my user only has execute permissions for the stored procedure within the database. The only thing that I've found so far that will fix this is if I change the user's permissions to db_owner, which I don't want to do.

I've tried to explicitly grant permission within the stored proc, but since the object (the temp table) does not actually reside in the database, that gives me an error as well (4610: You can only grant or revoke permissions on objects in the current database.).

Is there anything else I can do? I really don't want to have to give the user that much freedom within the database, and removing the dynamic SQL really isn't a viable option either.

Thanks in advance for your help!

Cat

If you are using SQL 2000, you have no choice. To use dynamic SQL requires a high level of permissions.

IF you are using SQL 2005, explore the 'EXECUTE AS' property.

Refer to Books Online, Topic: 'EXECUTE AS'

Permissions problem running xp_sendmail

SQL Server 2000 SP3 on Win2k Server SP3
Using code: EXEC master..xp_sendmail @.recipients=my_address_goes_here, @.mess
age='',
@.query='SELECT foo FROM bar', @.subject='Subject',
@.attachments='qry.csv',
@.attach_results='TRUE',
@.width=500,@.separator=','
Without @.attachments and @.attach_results the query runs and sends a mail con
taining data. However, it is a user requirement that I send the file as an a
ttached .csv so it will load directly into Excel. With @.attach_results set t
o TRUE and no @.attachments,
the code fails with xp_sendmail: failed with operating system error 267. I'v
e logged in as the SQL Server service account and set its TEMP and TMP envir
onment variables to a folder over which everyone has full control. When I us
e @.attachments, whether I
specify a path or not I get xp_sendmail: failed with operating system error
5.
This looks like a permissions problem, and I've seen several similar posting
s but without a solution. Can anyone point me in the right direction?
Thanks
Scott DoughtyShould also mention the server is clustered

Permissions problem running xp_sendmail

SQL Server 2000 SP3 on Win2k Server SP
Using code: EXEC master..xp_sendmail @.recipients=my_address_goes_here, @.message=''
@.query='SELECT foo FROM bar', @.subject='Subject'
@.attachments='qry.csv'
@.attach_results='TRUE'
@.width=500,@.separator=',
Without @.attachments and @.attach_results the query runs and sends a mail containing data. However, it is a user requirement that I send the file as an attached .csv so it will load directly into Excel. With @.attach_results set to TRUE and no @.attachments, the code fails with xp_sendmail: failed with operating system error 267. I've logged in as the SQL Server service account and set its TEMP and TMP environment variables to a folder over which everyone has full control. When I use @.attachments, whether I specify a path or not I get xp_sendmail: failed with operating system error 5
This looks like a permissions problem, and I've seen several similar postings but without a solution. Can anyone point me in the right direction
Thank
Scott DoughtShould also mention the server is clustered

Permissions problem

Hi
I have some code that I am testing to read data from a FoxPro file.
I have copied the FoxPro file locally to test.
I have created a linked server that points to this file. Enterprise manager
correctly shows the tables available.
Works fine.!
However, when I create another linked server pointing towards the network
files, enterprise manager shows no available tables and my code returns an
error stating that the table does not exist.
I have checked the security permissions on the network drive/directories and
I appear to have full access. I can indeed move, delete etc these files.
Any ideas why I cannot connect in enterprise manager.?
ThanksI can however import these tables using a DTS job.!!!
"Chubbly Geezer" wrote:

> Hi
> I have some code that I am testing to read data from a FoxPro file.
> I have copied the FoxPro file locally to test.
> I have created a linked server that points to this file. Enterprise manag
er
> correctly shows the tables available.
> Works fine.!
> However, when I create another linked server pointing towards the network
> files, enterprise manager shows no available tables and my code returns an
> error stating that the table does not exist.
> I have checked the security permissions on the network drive/directories a
nd
> I appear to have full access. I can indeed move, delete etc these files.
> Any ideas why I cannot connect in enterprise manager.?
> Thanks|||Hi
Does the account that SQL Server and Agent run under have permission on the
remote share and files?
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Chubbly Geezer" wrote:

> Hi
> I have some code that I am testing to read data from a FoxPro file.
> I have copied the FoxPro file locally to test.
> I have created a linked server that points to this file. Enterprise manag
er
> correctly shows the tables available.
> Works fine.!
> However, when I create another linked server pointing towards the network
> files, enterprise manager shows no available tables and my code returns an
> error stating that the table does not exist.
> I have checked the security permissions on the network drive/directories a
nd
> I appear to have full access. I can indeed move, delete etc these files.
> Any ideas why I cannot connect in enterprise manager.?
> Thanks|||Both services were running under local system. Have changed to my login but
still no joy.
Also in linked server security options I have tried changing them to login
as myself but no luck.
The following 2 lines of code ALSO return table data:
EXEC sp_tables_ex @.table_server='OPERA_SERVER'
EXEC sp_columns_ex @.table_server='OPERA_SERVER', @.table_name='ssale'
"Mike Epprecht (SQL MVP)" wrote:
> Hi
> Does the account that SQL Server and Agent run under have permission on th
e
> remote share and files?
> Regards
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
>
> "Chubbly Geezer" wrote:
>|||Correction.
The following 2 lines of code DO NOT WORK..
EXEC sp_tables_ex @.table_server='OPERA_SERVER'
EXEC sp_columns_ex @.table_server='OPERA_SERVER', @.table_name='ssale'
"Chubbly Geezer" wrote:
> Both services were running under local system. Have changed to my login b
ut
> still no joy.
> Also in linked server security options I have tried changing them to login
> as myself but no luck.
> The following 2 lines of code ALSO return table data:
> EXEC sp_tables_ex @.table_server='OPERA_SERVER'
> EXEC sp_columns_ex @.table_server='OPERA_SERVER', @.table_name='ssale'
>
> "Mike Epprecht (SQL MVP)" wrote:
>sql

Monday, March 12, 2012

Permissions for dll in rssrvpolicy.config

I have built some custom authentication library but have run into a problem.
The custom code uses MySql.Data.dll(a library from MySQL for .NET) to
authenticate users against a MySQL db.
I get an connection error when I attempt to connect and believe that it is
because of CodeGroup permissions that need to be set in the
rssrvpolicy.config file.
I have added a code group as:
<CodeGroup
class="UnionCodeGroup"
version="1"
Name="MySQL"
Description="Code group for the security extension MySQL"
PermissionSetName="FullTrust">
<IMembershipCondition
class="UrlMembershipCondition"
version="1"
Url="D:\Program Files\Microsoft SQL Server\MSSQL\Reporting
Services\ReportServer\bin\MySql.Data.dll"
/>
but still no sucess.
Any ideas? Are there any other security settings?
The server is 2003 with IIS 6.
ThanksI used filemon.exe from SysInternals.com to debug a security
permissions problem with my custom assembly recently. It will show you
if the dll is being loaded and if not, what is preventing it from being
loaded. My solution involved using the file properties - security tab
to compare the allowable user groups on the custom dll to other dll's
in the bin folder.
This may be an obvious question... you have given permission to the
MySQL.Data.dll, but have you given the correct permissions to your
custom dll that uses that library?
I have also seen other posts that comment on the placement of the code
group in the code group heirarchy. Most recommend placing new code
groups right under the root code group node. Let us know what you find.|||Thank so much for your thoughts.
I took your advice and changed the order of the code groups for the DLL's
and it worked. I have the MySQL dll entry followed by custom library.
What is also to be noted is that I did not have to add any entries for the
MySQL dll or my custom dll when I was working on 2000 server with IIS 5.0.
IIS 6.0 has much tighter security.
Problem solved.
Thanks again,
Kevin
<bcsmith@.gmail.com> wrote in message
news:1106250549.705855.130230@.c13g2000cwb.googlegroups.com...
>I used filemon.exe from SysInternals.com to debug a security
> permissions problem with my custom assembly recently. It will show you
> if the dll is being loaded and if not, what is preventing it from being
> loaded. My solution involved using the file properties - security tab
> to compare the allowable user groups on the custom dll to other dll's
> in the bin folder.
> This may be an obvious question... you have given permission to the
> MySQL.Data.dll, but have you given the correct permissions to your
> custom dll that uses that library?
> I have also seen other posts that comment on the placement of the code
> group in the code group heirarchy. Most recommend placing new code
> groups right under the root code group node. Let us know what you find.
>

Permissions

Does anyone know where the actual code for a stored procedure is stored at? Is it in a system table?your_database.syscomments - ctext field

Originally posted by justastef
Does anyone know where the actual code for a stored procedure is stored at? Is it in a system table?|||Looking in the syscolumns table, I noticed that all of my procedures only have the first part and the last part located in it if they are long. The middle is missing... is this due to the column being only 8000 characters long at a time so its missing a chunk... If this is the case, how can I extract the entire contents of the code of a stored procedure (not through a tool just through t-sql)... is there a command to extract this information?

I also noticed that I named the subject Permissions when I should have typed procedures... lol where is my head today.|||You're right. For each 8000 characters SQL inserts one row in syscomments table, so if you want to extract the text, you'll need to use a cursor and put the text somewhere in a flat file for instance.
I'm not aware of any T-SQL command to extract that info automatically.

Originally posted by justastef
Looking in the syscolumns table, I noticed that all of my procedures only have the first part and the last part located in it if they are long. The middle is missing... is this due to the column being only 8000 characters long at a time so its missing a chunk... If this is the case, how can I extract the entire contents of the code of a stored procedure (not through a tool just through t-sql)... is there a command to extract this information?

I also noticed that I named the subject Permissions when I should have typed procedures... lol where is my head today.

Wednesday, March 7, 2012

Permission Reading Registry from Assembly

======== REPOSTED w/MSDN ALIAS ======== We have a custom assembly used by our reports that needs to access SQL
Server and the Registry. In code, prior to making our SQL server
connection, we assert the System.Data.SqlClient.SqlClientPermission and we
are able to connect just fine. Prior to opening the registry key, we assert
the System.Security.Permissions.RegistryPermission, but on the subsequent
call to open the subkey, we get the following exception:
Request for the permission of type
System.Security.Permissions.RegistryPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
* We created a code group in the policy config file giving our assembly full
trust.
* The Everyone group has permissions to read the registry key and the value.
* We executed Sysinternal's registry monitor tool and it doesn't appear to
even log the call to open the key.
Environment: Visual Studio.NET 1.1, Reporting Services 1.1, Windows XP
====[BEGIN CODE SNIPPET]============== RegistryKey regTest = null;
try {
RegistryPermission regPermission = new
RegistryPermission(RegistryPermissionAccess.Read,
"HKEY_LOCAL_MACHINE\\SOFTWARE\\0");
regPermission.Assert();
regTest = Registry.LocalMachine;
regTest = regTest.OpenSubKey("SOFTWARE"); // This call fails with the
exception above
return (string)regTest.GetValue("TestVal");
} finally {
if (regTest != null) {
regTest.Close();
}
}
====[END CODE SNIPPET]==============
I don't think this is a registry permission issue since it says the
"request" for the permission failed. However, I would have expected the
request to fail on the assert, not on the subsequent OpenSubKey call.
Does anyone have any suggestions on how to troubleshoot this?
Thanks,
ChrisHi Chris,
Thank you for posting.
Regarding on the SSRS custom assembly registry accessing issue, I think we
should still troubleshoot from the permission setting. And what we can
check is the below things:
1. raw win32 registry access permission
2. .NET CAS permission setting.
For win32 registry access permission, the regmon tool should be able to
capture the failure error
For .NET CAS permission problem, you can consider temporarly turn off the
.net framework's CAS setting through the caspol.exe tool:
#Code Access Security Policy Tool (Caspol.exe) (.NET Framework)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/htm
l/cpgrfcodeaccesssecuritypolicyutilitycaspolexe.asp
After turn off the CAS and test the custom assembly again to see whether it
works.
Hope this helps.
Regards,
Steven Cheng
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)|||I have copied code out of the help file that opens the LocalMachine key and
calls GetSubKeys(). This fails with the same permissions error. I have
granted the Everyone group Full Control on the LocalMachine key. Using the
caspol.exe tool noted below, I have turned off CAS.
I have been running registry monitor from system internals, and unless I'm
using the tool incorrectly, I don't see any failures or successes. I am
using the RSReportHost to be able to execute the report and step through my
assembly. I don't know what process it would be using to access the
registry.
In regards to the suggestions below:
1. What other pemissions could I add in addition to granting the Everyone
group Full Control? I am still getting the exception.
2. As stated above, I executed the caspol.exe turning off CAS. I am still
getting the exception.
- Chris
=================================Taken from the Registry.LocalMachine field help file sample:
public static string PrintKeys() {
StringBuilder sbResult = new StringBuilder();
RegistryKey rk = Registry.LocalMachine;
// Retrieve all the subkeys for the specified key.
String [] names;
try {
names = rk.GetSubKeyNames(); <=== BOOM
} catch (Exception e) {
return e.Message;
}
int icount = 0;
// Print the contents of the array to the console.
foreach (String s in names) {
sbResult.Append(s);
// The following code puts a limit on the number
// of keys displayed. Comment it out to print the
// complete list.
icount++;
if (icount >= 10)
break;
}
return sbResult.ToString();
}
"Steven Cheng[MSFT]" <stcheng@.online.microsoft.com> wrote in message
news:eeLJoQfWGHA.932@.TK2MSFTNGXA01.phx.gbl...
> Hi Chris,
> Thank you for posting.
> Regarding on the SSRS custom assembly registry accessing issue, I think we
> should still troubleshoot from the permission setting. And what we can
> check is the below things:
> 1. raw win32 registry access permission
> 2. .NET CAS permission setting.
> For win32 registry access permission, the regmon tool should be able to
> capture the failure error
> For .NET CAS permission problem, you can consider temporarly turn off the
> net framework's CAS setting through the caspol.exe tool:
> #Code Access Security Policy Tool (Caspol.exe) (.NET Framework)
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/htm
> l/cpgrfcodeaccesssecuritypolicyutilitycaspolexe.asp
> After turn off the CAS and test the custom assembly again to see whether
> it
> works.
> Hope this helps.
> Regards,
> Steven Cheng
> Microsoft Online Community Support
>
> ==================================================> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>|||Clarification - When running the RegMon tool, I do see a lot of activity
from other processes, but nothing that I can identify being associated with
my custom assembly.
"Chris Walls" <chwalls2@.community.nospam> wrote in message
news:OIlWD$WXGHA.3492@.TK2MSFTNGP05.phx.gbl...
>I have copied code out of the help file that opens the LocalMachine key and
>calls GetSubKeys(). This fails with the same permissions error. I have
>granted the Everyone group Full Control on the LocalMachine key. Using the
>caspol.exe tool noted below, I have turned off CAS.
> I have been running registry monitor from system internals, and unless I'm
> using the tool incorrectly, I don't see any failures or successes. I am
> using the RSReportHost to be able to execute the report and step through
> my assembly. I don't know what process it would be using to access the
> registry.
> In regards to the suggestions below:
> 1. What other pemissions could I add in addition to granting the Everyone
> group Full Control? I am still getting the exception.
> 2. As stated above, I executed the caspol.exe turning off CAS. I am still
> getting the exception.
> - Chris
> =================================> Taken from the Registry.LocalMachine field help file sample:
> public static string PrintKeys() {
> StringBuilder sbResult = new StringBuilder();
> RegistryKey rk = Registry.LocalMachine;
> // Retrieve all the subkeys for the specified key.
> String [] names;
> try {
> names = rk.GetSubKeyNames(); <=== BOOM
> } catch (Exception e) {
> return e.Message;
> }
> int icount = 0;
> // Print the contents of the array to the console.
> foreach (String s in names) {
> sbResult.Append(s);
> // The following code puts a limit on the number
> // of keys displayed. Comment it out to print the
> // complete list.
> icount++;
> if (icount >= 10)
> break;
> }
> return sbResult.ToString();
> }
>
> "Steven Cheng[MSFT]" <stcheng@.online.microsoft.com> wrote in message
> news:eeLJoQfWGHA.932@.TK2MSFTNGXA01.phx.gbl...
>> Hi Chris,
>> Thank you for posting.
>> Regarding on the SSRS custom assembly registry accessing issue, I think
>> we
>> should still troubleshoot from the permission setting. And what we can
>> check is the below things:
>> 1. raw win32 registry access permission
>> 2. .NET CAS permission setting.
>> For win32 registry access permission, the regmon tool should be able to
>> capture the failure error
>> For .NET CAS permission problem, you can consider temporarly turn off the
>> net framework's CAS setting through the caspol.exe tool:
>> #Code Access Security Policy Tool (Caspol.exe) (.NET Framework)
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/htm
>> l/cpgrfcodeaccesssecuritypolicyutilitycaspolexe.asp
>> After turn off the CAS and test the custom assembly again to see whether
>> it
>> works.
>> Hope this helps.
>> Regards,
>> Steven Cheng
>> Microsoft Online Community Support
>>
>> ==================================================>> When responding to posts, please "Reply to Group" via your newsreader so
>> that others may learn and benefit from your issue.
>> ==================================================>>
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>> Get Secure! www.microsoft.com/security
>> (This posting is provided "AS IS", with no warranties, and confers no
>> rights.)
>|||Thanks for your followup Chris,
This seems strange, so far I can not consider any other particular security
related setting either. Should be a environment specific issue. Have you
tried creating a new custom assembly which access some certain registry to
see whether it also suffer the probelm on ths machine?
Regards,
Steven Cheng
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.|||I got a little further. I created a new assembly that only had my registry
code. I ran it as a console application and it successfully read my
registry values. I saw in RegMon that the keys where opened, queried, etc.
I then changed it to a class library and referenced it with a test report.
I was receiving the same permission errors. I turned off security via the
caspol utility and then I was able to successfully read my values. I then
modified my test report to reference my first assembly and it too now works.
Clearly I didn't disable security the last time like I thought I did.
So cleary my entries in the rspreviewpolicy.config file is incorrect. I
thought I was granting full trust to my assembly. Here is my entries. They
are at the end of the file just before the </policy> end tag.
<CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust"
Name="TSIRegistryTest">
<IMembershipCondition
class="UrlMembershipCondition"
version="1" Url="C:\Program Files\Microsoft SQL Server\80\Tools\Report
Designer\ReportTest.dll" />
</CodeGroup>
Any help would be greatly appreciated.
- Chris
"Steven Cheng[MSFT]" <stcheng@.online.microsoft.com> wrote in message
news:N9KImB8XGHA.888@.TK2MSFTNGXA01.phx.gbl...
> Thanks for your followup Chris,
> This seems strange, so far I can not consider any other particular
> security
> related setting either. Should be a environment specific issue. Have you
> tried creating a new custom assembly which access some certain registry to
> see whether it also suffer the probelm on ths machine?
> Regards,
> Steven Cheng
> Microsoft Online Community Support
>
> ==================================================> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>|||Thank you for the response Chris,
So your custom assembly is put in the following location:
C:\Program Files\Microsoft SQL Server\80\Tools\Report
Designer\ReportTest.dll
If so, I think the <CodeGroup > element you pasted should be ok. And the
problem is possibly caused by the location where you add the custom
<codeGroup> in the policy file. As you mentioend that you add it at the
end of the file just before the </policy> end tag. Do you mean that it is
not included/nested within other <codeGroup> ?, like below:
======================...other code group here
<!--
Your code group here?
-->
</PolicyLevel>
</policy>
</security>
</mscorlib>
</configuration>
==========================
If so, it is not the correct place since the codegroup in .NET code access
policy file is not a flat structure, they're hierarchical and nested...
And our custom code should be put within a "Local Computer"
firstMatchCodeGroup, it is as below:
================= <CodeGroup
class="FirstMatchCodeGroup"
version="1"
PermissionSetName="Execution"
Description="This code group grants
MyComputer code Execution permission. ">
<IMembershipCondition
class="ZoneMembershipCondition"
version="1"
Zone="MyComputer" />
<!--
many parallel nested sub codegroups here....
-->
</CodeGroup>
==============
You'll find there is many other sub codegroups nested inside it which are
parallel with each other. If you find it, you can try puting your custom
code group as the sub nested codegroup within it. In addition, you can
also try strong-named your assembly and put it in GAC, then use
strong-named membershipCondition to idenitify it for testing.
BTW, here is a good msdn article describing the code access security in
ASP.NET application(including customizing policy file):
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html
/paght000017.asp
Hope this also helps.
Regards,
Steven Cheng
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)|||Ok, I think I got it. One thing that was screwing me up is that the change
in the rspreviewpolicy.config was not being picked up by the RSReportHost
utility, even when I unloaded and reloaded it. Only when I started
previewing the report with VS.NET did I see a successful execution with CAS
turned on. Now I'm having similar issues on the build server, but I have a
better understanding of how to troubleshoot it.
Thanks for all of the help.
- Chris
"Steven Cheng[MSFT]" <stcheng@.online.microsoft.com> wrote in message
news:J8C4%23YEZGHA.6000@.TK2MSFTNGXA01.phx.gbl...
> Thank you for the response Chris,
> So your custom assembly is put in the following location:
> C:\Program Files\Microsoft SQL Server\80\Tools\Report
> Designer\ReportTest.dll
> If so, I think the <CodeGroup > element you pasted should be ok. And the
> problem is possibly caused by the location where you add the custom
> <codeGroup> in the policy file. As you mentioend that you add it at the
> end of the file just before the </policy> end tag. Do you mean that it is
> not included/nested within other <codeGroup> ?, like below:
> ======================> ...other code group here
> <!--
> Your code group here?
> -->
> </PolicyLevel>
> </policy>
> </security>
> </mscorlib>
> </configuration>
> ==========================> If so, it is not the correct place since the codegroup in .NET code access
> policy file is not a flat structure, they're hierarchical and nested...
> And our custom code should be put within a "Local Computer"
> firstMatchCodeGroup, it is as below:
> =================> <CodeGroup
> class="FirstMatchCodeGroup"
> version="1"
> PermissionSetName="Execution"
> Description="This code group grants
> MyComputer code Execution permission. ">
> <IMembershipCondition
> class="ZoneMembershipCondition"
> version="1"
> Zone="MyComputer" />
> <!--
> many parallel nested sub codegroups here....
> -->
> </CodeGroup>
> ==============> You'll find there is many other sub codegroups nested inside it which are
> parallel with each other. If you find it, you can try puting your custom
> code group as the sub nested codegroup within it. In addition, you can
> also try strong-named your assembly and put it in GAC, then use
> strong-named membershipCondition to idenitify it for testing.
> BTW, here is a good msdn article describing the code access security in
> ASP.NET application(including customizing policy file):
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html
> /paght000017.asp
> Hope this also helps.
> Regards,
> Steven Cheng
> Microsoft Online Community Support
>
> ==================================================> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>
>
>
>
>
>
>|||Thanks for your followup Chris,
I'm very glad that you've made progress on this. Also, it's a pleasure to
be of assistance.
Please feel free to post here when there is anything else we can help you.
Good luck!
Regards,
Steven Cheng
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Saturday, February 25, 2012

Permission issues in Dynamic Querries

I am trying to run this piece of SQL code in an SP, as a database user calle
d 'xsndev'.
--
DECLARE @.testvar VARCHAR(1000)
SET @.testvar = 'Update XSN_Links_Games SET player1hole7stroke=0, player2hole
7stroke=0 WHERE linksgameid=0'
exec(@.testvar)
GO
--
And I am getting this error:
--
Server: Msg 229, Level 14, State 5, Line 1
SELECT permission denied on object 'XSN_Links_Games', database 'XSNDEV', own
er 'dbo'.
Server: Msg 229, Level 14, State 1, Line 1
UPDATE permission denied on object 'XSN_Links_Games', database 'XSNDEV', own
er 'dbo'.
--
Whereas if I run the same code with login 'sa' which is the dbo of the datab
ase, SP runs smoothly.
I have give permission to 'xsndev' user on the above table and the stored pr
ocedure, but still same error occurs.
Is there any other configuration or setting I need to change for the dynamic
sql to work?
Thanks,
RohitThis is by design for dynamic query. You have to give permission on the base
object(s) to the executing user(s).
-oj
http://www.rac4sql.net
"Rohit" <anonymous@.discussions.microsoft.com> wrote in message
news:8A6AA900-8267-4A4C-B0CE-0731AEDE6CB1@.microsoft.com...
quote:

> I am trying to run this piece of SQL code in an SP, as a database user

called 'xsndev'.
quote:

> --
> DECLARE @.testvar VARCHAR(1000)
> SET @.testvar = 'Update XSN_Links_Games SET player1hole7stroke=0,

player2hole7stroke=0 WHERE linksgameid=0'
quote:

> exec(@.testvar)
> GO
> --
> And I am getting this error:
> --
> Server: Msg 229, Level 14, State 5, Line 1
> SELECT permission denied on object 'XSN_Links_Games', database 'XSNDEV',

owner 'dbo'.
quote:

> Server: Msg 229, Level 14, State 1, Line 1
> UPDATE permission denied on object 'XSN_Links_Games', database 'XSNDEV',

owner 'dbo'.
quote:

> --
> Whereas if I run the same code with login 'sa' which is the dbo of the

database, SP runs smoothly.
quote:

> I have give permission to 'xsndev' user on the above table and the stored

procedure, but still same error occurs.
quote:

> Is there any other configuration or setting I need to change for the

dynamic sql to work?
quote:

> Thanks,
> Rohit
>
|||Hi OJ,
I dont think I understand your answer entirely. What is the base object
you are talking about? I have given permissions to the 'xsndev' user on the
table 'XSN_Links_Games' Table.
Thanks,
Rohit
-- oj wrote: --
This is by design for dynamic query. You have to give permission on the base
object(s) to the executing user(s).
-oj
http://www.rac4sql.net
"Rohit" <anonymous@.discussions.microsoft.com> wrote in message
news:8A6AA900-8267-4A4C-B0CE-0731AEDE6CB1@.microsoft.com...
quote:

> I am trying to run this piece of SQL code in an SP, as a database user

called 'xsndev'.
quote:

> --
> DECLARE @.testvar VARCHAR(1000)
> SET @.testvar = 'Update XSN_Links_Games SET player1hole7stroke=0,

player2hole7stroke=0 WHERE linksgameid=0'
quote:

> exec(@.testvar)
> GO
> --
> And I am getting this error:
> --
> Server: Msg 229, Level 14, State 5, Line 1
> SELECT permission denied on object 'XSN_Links_Games', database 'XSNDEV',

owner 'dbo'.
quote:

> Server: Msg 229, Level 14, State 1, Line 1
> UPDATE permission denied on object 'XSN_Links_Games', database 'XSNDEV',

owner 'dbo'.[QUOTE]
> --
database, SP runs smoothly.[QUOTE]
procedure, but still same error occurs.[QUOTE]
dynamic sql to work?[QUOTE]
> Rohit

Permission issues in Dynamic Querries

I am trying to run this piece of SQL code in an SP, as a database user called 'xsndev'.
--
DECLARE @.testvar VARCHAR(1000)
SET @.testvar = 'Update XSN_Links_Games SET player1hole7stroke=0, player2hole7stroke=0 WHERE linksgameid=0'
exec(@.testvar)
GO
--
And I am getting this error:
--
Server: Msg 229, Level 14, State 5, Line 1
SELECT permission denied on object 'XSN_Links_Games', database 'XSNDEV', owner 'dbo'.
Server: Msg 229, Level 14, State 1, Line 1
UPDATE permission denied on object 'XSN_Links_Games', database 'XSNDEV', owner 'dbo'.
--
Whereas if I run the same code with login 'sa' which is the dbo of the database, SP runs smoothly.
I have give permission to 'xsndev' user on the above table and the stored procedure, but still same error occurs.
Is there any other configuration or setting I need to change for the dynamic sql to work?
Thanks,
RohitThis is by design for dynamic query. You have to give permission on the base
object(s) to the executing user(s).
--
-oj
http://www.rac4sql.net
"Rohit" <anonymous@.discussions.microsoft.com> wrote in message
news:8A6AA900-8267-4A4C-B0CE-0731AEDE6CB1@.microsoft.com...
> I am trying to run this piece of SQL code in an SP, as a database user
called 'xsndev'.
> --
> DECLARE @.testvar VARCHAR(1000)
> SET @.testvar = 'Update XSN_Links_Games SET player1hole7stroke=0,
player2hole7stroke=0 WHERE linksgameid=0'
> exec(@.testvar)
> GO
> --
> And I am getting this error:
> --
> Server: Msg 229, Level 14, State 5, Line 1
> SELECT permission denied on object 'XSN_Links_Games', database 'XSNDEV',
owner 'dbo'.
> Server: Msg 229, Level 14, State 1, Line 1
> UPDATE permission denied on object 'XSN_Links_Games', database 'XSNDEV',
owner 'dbo'.
> --
> Whereas if I run the same code with login 'sa' which is the dbo of the
database, SP runs smoothly.
> I have give permission to 'xsndev' user on the above table and the stored
procedure, but still same error occurs.
> Is there any other configuration or setting I need to change for the
dynamic sql to work?
> Thanks,
> Rohit
>|||Hi OJ,
I dont think I understand your answer entirely. What is the base object
you are talking about? I have given permissions to the 'xsndev' user on the
table 'XSN_Links_Games' Table.
Thanks,
Rohit
-- oj wrote: --
This is by design for dynamic query. You have to give permission on the base
object(s) to the executing user(s).
--
-oj
http://www.rac4sql.net
"Rohit" <anonymous@.discussions.microsoft.com> wrote in message
news:8A6AA900-8267-4A4C-B0CE-0731AEDE6CB1@.microsoft.com...
> I am trying to run this piece of SQL code in an SP, as a database user
called 'xsndev'.
> --
> DECLARE @.testvar VARCHAR(1000)
> SET @.testvar = 'Update XSN_Links_Games SET player1hole7stroke=0,
player2hole7stroke=0 WHERE linksgameid=0'
> exec(@.testvar)
> GO
> --
> And I am getting this error:
> --
> Server: Msg 229, Level 14, State 5, Line 1
> SELECT permission denied on object 'XSN_Links_Games', database 'XSNDEV',
owner 'dbo'.
> Server: Msg 229, Level 14, State 1, Line 1
> UPDATE permission denied on object 'XSN_Links_Games', database 'XSNDEV',
owner 'dbo'.
> --
>> Whereas if I run the same code with login 'sa' which is the dbo of the
database, SP runs smoothly.
>> I have give permission to 'xsndev' user on the above table and the stored
procedure, but still same error occurs.
>> Is there any other configuration or setting I need to change for the
dynamic sql to work?
>> Thanks,
> Rohit
>>

permission grant set is incompatible between appdomains

HI ,
I have a custom dll that I use to do some of the code expressions across
reports. I have set the required permissions in the rsrvpolicy.config file to
allow it to run under full trust. I have also set the following attributes
on the method in that dll
<System.Security.Permissions.EnvironmentPermission(Security.Permissions.SecurityAction.Assert, Unrestricted:=True),
System.Net.WebPermission(Security.Permissions.SecurityAction.Assert,
Unrestricted:=True)>
Everything was fine till yesterday. Yesterday, my machine was added to be a
member of a domain. I am not getting this error when I try to access the
reports:
rsProcessingError 400 Failed to load expression host assembly. Details:
Assembly mycustom.dll security permission grant set is incompatible between
appdomains.
http://go.microsoft.com/fwlink/?LinkId=20476&EvtSrc=Microsoft.ReportingServices.Diagnostics.Utilities.ErrorStrings.resources.Strings&EvtID=rsProcessingError&ProdName=Microsoft%20SQL%20Server%20Reporting%20Services&ProdVer=8.00
Microsoft SQL Server Reporting Services 8.00.743.00 127 OsIndependent 1033
Microsoft.ReportingServices.Processing Failed to load expression host
assembly. Details: Assembly mycustom.dll security permission grant set is
incompatible between appdomains
Please help!Never mind.
I got some notes by searching in google that fixed this problem. I just had
to restart IIS.
and it starting working
Thanks
George