Showing posts with label unique. Show all posts
Showing posts with label unique. Show all posts

Friday, March 30, 2012

Role based security question

First Off:
SQL Server 2005 Std edit.
RS 2005
Windows Server 2003 Std edit.
Active Directory

I seem to have a unique problem with my Report Server setup. Right now when any of our users attempt to access Report Server, they are prompted for username and password. They enter their username as: domain\username and then enter their password (active directory is enabled). We have no issue with authentication, everyone can get into the server without a problem.

Where the problem lies is after login. No matter what roles I assign to any folder in report server, it seems as though everyone has administrator access to RS. For example, under Site Settings I click Configure Site-Wide Security and add the BUILTIN\Users group as System Users. After applying the change, users are still able to login and change any system level setting they wish to. I've tried using Domain\Domain Users and no luck. I tried adding an individual user as a System User and when logging in as them I can change any system settings I want.

Same goes for setting security on folders in RS. Right now on the Home folder I have security set so that the BUILTIN\Users group has Browser access, yet all users can edit/delete/set properties and generally just behave like admins on any items within the Home folder. I tried adding individual users and limiting their access, other active directory groups, everything but the kitchen sink and yet they are always able to behave like an admin.

The documentation states that after installation of RS, no one but the BUILTIN\Administrator account can access the server. I did not find this to be the case though, as users I had test the installation were able to access it right off the bat. In fact if I remove all groups but BUILTIN\Administrator from the Home folder, everyone can still see all of the reports without issue.

I'll be the first to admit that I am new to all of this and I am wearing many hats at the moment, but this security issue has me stumped. I've searched Google, the forums, read MSDN up and down, have several RS books and yet here I am. Can anyone shed some light on this for me?

Thanks in Advance.

EDIT - I just checked the virtual directories for Reports and ReportServer and the BUILTIN\Users group has the following access: Read, List Folder Content and Read & Execute. Could this be why I can't set role permissions in Report Server?

OMG, nevermind. It seems that after some deep investigation all of the ID's I was using to access the Report Server were buried in a groupthat was nested in another group that was nested within the Administrators group. I got so fed up I created a new ID and logged into RS and security was working as expected. Once again I post, only to discover it is all user error. Sorry all.

J

Wednesday, March 28, 2012

Robust unique identifiers?

Hi there ... after much research i still can't quite find the right
answer to this problem, so here goes.
I'm trying to find a simple, robust and scalable way to manage unique
identifiers in my database system. The system generates paper forms
containing the UIDs and sends them to customers, so maintaining
integrity of the numbers is critical.
The system needs to be non-DBMS-specific, needs to be able to run in
multiple instances simultaneously (although this is only a
hypothetical, later requirement) and needs to be as robust as possible
throughout DB restores, general maintenance and against rogue DBAs
resetting IDENTITYs and the like.
I've been looking at generating a unique key using a hashed combination
of the server ID and a low-level timestamp, which is fine except that
it generates enormous numbers. Customers need to be able to quote the
numbers easily to call centre staff, so I'm looking for something
ideally no more than about 12-16 digits. Is there a quality random
value generator that will give numbers as short as this? Or, is there a
suitably robust way of using SQL IDENTITYs to achieve what I need?
Many thanks for any help.
Pete.Allocate the first digit (or more if you need) to identify the server
instance - 1 number per server. The rest can just be an incrementing count.
Won't that meet your requirements?
David Portas
SQL Server MVP
--

Robust unique identifiers?

Hi there ... after much research i still can't quite find the right
answer to this problem, so here goes.
I'm trying to find a simple, robust and scalable way to manage unique
identifiers in my database system. The system generates paper forms
containing the UIDs and sends them to customers, so maintaining
integrity of the numbers is critical.
The system needs to be non-DBMS-specific, needs to be able to run in
multiple instances simultaneously (although this is only a
hypothetical, later requirement) and needs to be as robust as possible
throughout DB restores, general maintenance and against rogue DBAs
resetting IDENTITYs and the like.
I've been looking at generating a unique key using a hashed combination
of the server ID and a low-level timestamp, which is fine except that
it generates enormous numbers. Customers need to be able to quote the
numbers easily to call centre staff, so I'm looking for something
ideally no more than about 12-16 digits. Is there a quality random
value generator that will give numbers as short as this? Or, is there a
suitably robust way of using SQL IDENTITYs to achieve what I need?
Many thanks for any help.
Pete.Allocate the first digit (or more if you need) to identify the server
instance - 1 number per server. The rest can just be an incrementing count.
Won't that meet your requirements?
David Portas
SQL Server MVP
--

Robust unique identifiers?

Hi there ... after much research i still can't quite find the right
answer to this problem, so here goes.
I'm trying to find a simple, robust and scalable way to manage unique
identifiers in my database system. The system generates paper forms
containing the UIDs and sends them to customers, so maintaining
integrity of the numbers is critical.
The system needs to be non-DBMS-specific, needs to be able to run in
multiple instances simultaneously (although this is only a
hypothetical, later requirement) and needs to be as robust as possible
throughout DB restores, general maintenance and against rogue DBAs
resetting IDENTITYs and the like.
I've been looking at generating a unique key using a hashed combination
of the server ID and a low-level timestamp, which is fine except that
it generates enormous numbers. Customers need to be able to quote the
numbers easily to call centre staff, so I'm looking for something
ideally no more than about 12-16 digits. Is there a quality random
value generator that will give numbers as short as this? Or, is there a
suitably robust way of using SQL IDENTITYs to achieve what I need?
Many thanks for any help.
Pete.Allocate the first digit (or more if you need) to identify the server
instance - 1 number per server. The rest can just be an incrementing count.
Won't that meet your requirements?
--
David Portas
SQL Server MVP
--

Robust unique identifiers?

Hi there ... after much research i still can't quite find the right
answer to this problem, so here goes.
I'm trying to find a simple, robust and scalable way to manage unique
identifiers in my database system. The system generates paper forms
containing the UIDs and sends them to customers, so maintaining
integrity of the numbers is critical.
The system needs to be non-DBMS-specific, needs to be able to run in
multiple instances simultaneously (although this is only a
hypothetical, later requirement) and needs to be as robust as possible
throughout DB restores, general maintenance and against rogue DBAs
resetting IDENTITYs and the like.
I've been looking at generating a unique key using a hashed combination
of the server ID and a low-level timestamp, which is fine except that
it generates enormous numbers. Customers need to be able to quote the
numbers easily to call centre staff, so I'm looking for something
ideally no more than about 12-16 digits. Is there a quality random
value generator that will give numbers as short as this? Or, is there a
suitably robust way of using SQL IDENTITYs to achieve what I need?
Many thanks for any help.
Pete.
Allocate the first digit (or more if you need) to identify the server
instance - 1 number per server. The rest can just be an incrementing count.
Won't that meet your requirements?
David Portas
SQL Server MVP
sql

Wednesday, March 7, 2012

Returning values from unique index

I have a table1(key, field1, field2, field3...).
My primary key is "key".
Then i create a unique index for fields "field1" and "field2".
This works, but i want that sql server retrieve me the values thar are being
duplicated.
I'm using sql server 7.0.
Ex: Table1 as the following values:
-0;0;0;0;
-1;1;1;1;
-2;2;2;2;
I have a second table with the values:
-3;3;3;3;
-4;1;1;1;
-5;0;0;0;
-6;0;0;0;
if i do a insert (insert into table1 select * from table2), it gives me an
error but i want that sql tell me that the error was because of values
4;1;1;1-5;0;0;0-6;0;0;0.
I hope this helps.
Can anyone help me?What was the error you got?
Madhivanan|||SQL Server won't identify the duplicated rows automatically for you.
You'll have to do a separate query:
SELECT T2.col1, T2.col2, T2.col3, T2.col4
FROM Table2 AS T2
JOIN Table1 AS T1
ON T1.col1 = T2.col1
AND T1.col2 = T2.col2
You could also insert only the unique rows as follows:
INSERT INTO Table1 (col1, col2, cole, col4)
SELECT T2.col1, T2.col2, T2.col3, T2.col4
FROM Table2 AS T2
LEFT JOIN Table1 AS T1
ON T1.col1 = T2.col1
AND T1.col2 = T2.col2
WHERE T1.col1 IS NULL
David Portas
SQL Server MVP
--|||Hi David,

INSERT INTO Table1 (col1, col2, cole, col4)
SELECT T2.col1, T2.col2, T2.col3, T2.col4
FROM Table2 AS T2
LEFT JOIN Table1 AS T1
ON T1.col1 = T2.col1
AND T1.col2 = T2.col2
WHERE T1.col1 IS NULL <<
I think that a DISTINCT should be added to the SELECT list.
Cheers,
--
BG, SQL Server MVP
www.SolidQualityLearning.com
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1111143246.610107.236070@.g14g2000cwa.googlegroups.com...
> SQL Server won't identify the duplicated rows automatically for you.
> You'll have to do a separate query:
> SELECT T2.col1, T2.col2, T2.col3, T2.col4
> FROM Table2 AS T2
> JOIN Table1 AS T1
> ON T1.col1 = T2.col1
> AND T1.col2 = T2.col2
> You could also insert only the unique rows as follows:
> INSERT INTO Table1 (col1, col2, cole, col4)
> SELECT T2.col1, T2.col2, T2.col3, T2.col4
> FROM Table2 AS T2
> LEFT JOIN Table1 AS T1
> ON T1.col1 = T2.col1
> AND T1.col2 = T2.col2
> WHERE T1.col1 IS NULL
> --
> David Portas
> SQL Server MVP
> --
>|||On Fri, 18 Mar 2005 10:26:40 -0000, Joaquim Meireles wrote:

>I have a table1(key, field1, field2, field3...).
>My primary key is "key".
>Then i create a unique index for fields "field1" and "field2".
>This works, but i want that sql server retrieve me the values thar are bein
g
>duplicated.
>I'm using sql server 7.0.
>Ex: Table1 as the following values:
> -0;0;0;0;
> -1;1;1;1;
> -2;2;2;2;
>I have a second table with the values:
> -3;3;3;3;
> -4;1;1;1;
> -5;0;0;0;
> -6;0;0;0;
>if i do a insert (insert into table1 select * from table2), it gives me an
>error but i want that sql tell me that the error was because of values
>4;1;1;1-5;0;0;0-6;0;0;0.
Hi Joaquim,
A constraint won't do that - a constraint simply constrains, that's all.
As David says, you need to use a query. However, the query he posted
won't return all duplicate rows. Try this one instead:
SELECT T2.key, T2.col1, T2.col2, T2.col3, T2.col4
FROM Table2 AS T2
LEFT JOIN Table1 AS T1
ON T1.col1 = T2.col1
AND T1.col2 = T2.col2
WHERE T1.key IS NOT NULL
OR EXISTS (SELECT *
FROM Table2 AS T2b
WHERE T2b.col1 = T2.col1
AND T2b.col2 = T2.col2
AND T2b.key <> T2.key)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

returning value from sql to c#

hello,
I have a small problem. i'm adding records into the DB. the primary keyis the company name which is abviously unique. before saving the recordi check in the stored procedure if the company code is unique or not.if unique then the record is added & an output parameter is set to2 & should b returned to the data access layer. if not unique then3 should be returned. but everytime it seems to be returning 2 whetherit is unique or not. can u plz help me? here is the code of the dataaccess layer:
cmd.Parameters.Add("@.Status", SqlDbType.Int);
cmd.Parameters["@.Status"].Value = ParameterDirection.ReturnValue;

//cmd.UpdatedRowSource = UpdatedRowSource.OutputParameters;
cmd.ExecuteNonQuery();
status = (int)cmd.Parameters["@.Status"].Value;

here is the stored procedure:
CREATE PROCEDURE spOrganizationAdd(
@.OrgCode varchar(10),
@.OrgName varchar(50),
@.AddressLine1 varchar(30),
@.AddressLine2 varchar(30),
@.City varchar(15),
@.State varchar(15),
@.Country varchar(15),
@.PinCode varchar(7),
@.Phone varchar(20),
@.Fax varchar(20),
@.Website varchar(30),
@.Email varchar(50),
@.CreatedBy int,
@.LastModifiedBy int,
@.Status INTEGER OUTPUT) AS
BEGIN TRAN
IF EXISTS(SELECT OrgCode FROM tblOrganizationMaster WHERE OrgCode = @.OrgCode)
BEGIN
SET @.Status = 3

END
ELSE
BEGIN
INSERT INTO tblOrganizationMaster VALUES(
@.OrgCode,
@.OrgName,
@.AddressLine1 ,
@.AddressLine2 ,
@.City ,
@.State,
@.Country,
@.PinCode,
@.Phone,
@.Fax ,
@.Website,
@.Email,
@.CreatedBy ,
GETDATE(),
@.LastModifiedBy ,
GETDATE())
SET @.Status = 2
END
IF @.@.ERROR = 0 COMMIT TRAN
ELSE ROLLBACK TRAN

plz reply as soon as possible.

Change this:

cmd.Parameters.Add("@.Status", SqlDbType.Int);
cmd.Parameters["@.Status"].Value = ParameterDirection.ReturnValue;

To this:

cmd.Parameters.Add("@.Status", SqlDbType.Int);
cmd.Parameters["@.Status"].Direction = ParameterDirection.Output;

and then it should work.

Bill

returning unique data

I have a table with 3 columns: number, name, rowid (and identity column). I
want to return the name of the first row (first meaning lowest rowid) when
there are more than one row with the same number. Given the table looks
like this:
number name rowid
102 bob 1
102 allen 2
104 carl 3
104 mike 4
I want only bob and carl to be returned.
Can anyone point me in the right direction?
Tx for any help.
Bernie YaegerYou're looking for a correlated subquery.
CREATE TABLE #foo
(
rowid INT IDENTITY(1,1),
[name] VARCHAR(12),
[number] INT
)
SET NOCOUNT ON
INSERT #foo([name], [number]) SELECT 'bob', 102
INSERT #foo([name], [number]) SELECT 'allen', 102
INSERT #foo([name], [number]) SELECT 'carl', 104
INSERT #foo([name], [number]) SELECT 'mike', 104
SELECT [name],[number],rowid
FROM #foo f1
WHERE rowid = (SELECT MIN(rowid)
FROM #foo f2
WHERE f2.[number] = f1.[number])
ORDER BY [number]
DROP TABLE #foo
"Bernie Yaeger" <berniey@.optonline.net> wrote in message
news:eN$erwlkFHA.1384@.TK2MSFTNGP10.phx.gbl...
>I have a table with 3 columns: number, name, rowid (and identity column).
>I want to return the name of the first row (first meaning lowest rowid)
>when there are more than one row with the same number. Given the table
>looks like this:
> number name rowid
> 102 bob 1
> 102 allen 2
> 104 carl 3
> 104 mike 4
> I want only bob and carl to be returned.
> Can anyone point me in the right direction?
> Tx for any help.
> Bernie Yaeger
>|||Bernie
CREATE TABLE #Test
(
[ID] INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
number INT NOT NULL,
[name]CHAR(1)NOT NULL,
rowid INT NOT NULL
)
INSERT INTO #Test(number,[name],rowid) VALUES (102,'A',2)
INSERT INTO #Test (number,[name],rowid)VALUES (102,'B',1)
INSERT INTO #Test(number,[name],rowid) VALUES (103,'C',1)
INSERT INTO #Test(number,[name],rowid) VALUES (103,'D',2)
INSERT INTO #Test(number,[name],rowid) VALUES (103,'A',3)
INSERT INTO #Test(number,[name],rowid) VALUES (103,'B',4)
INSERT INTO #Test(number,[name],rowid) VALUES (102,'T',0)
INSERT INTO #Test(number,[name],rowid) VALUES (104,'a',2)
SELECT [name]FROM #Test
WHERE rowid=(SELECT MIN(rowid) FROM #Test T WHERE T.number=#Test.number)
"Bernie Yaeger" <berniey@.optonline.net> wrote in message
news:eN$erwlkFHA.1384@.TK2MSFTNGP10.phx.gbl...
>I have a table with 3 columns: number, name, rowid (and identity column).
>I want to return the name of the first row (first meaning lowest rowid)
>when there are more than one row with the same number. Given the table
>looks like this:
> number name rowid
> 102 bob 1
> 102 allen 2
> 104 carl 3
> 104 mike 4
> I want only bob and carl to be returned.
> Can anyone point me in the right direction?
> Tx for any help.
> Bernie Yaeger
>|||Hi Uri,
Tx for your help Uri.
Bernie
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:eLVoxKmkFHA.3568@.TK2MSFTNGP10.phx.gbl...
> Bernie
> CREATE TABLE #Test
> (
> [ID] INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
> number INT NOT NULL,
> [name]CHAR(1)NOT NULL,
> rowid INT NOT NULL
> )
> INSERT INTO #Test(number,[name],rowid) VALUES (102,'A',2)
> INSERT INTO #Test (number,[name],rowid)VALUES (102,'B',1)
> INSERT INTO #Test(number,[name],rowid) VALUES (103,'C',1)
> INSERT INTO #Test(number,[name],rowid) VALUES (103,'D',2)
> INSERT INTO #Test(number,[name],rowid) VALUES (103,'A',3)
> INSERT INTO #Test(number,[name],rowid) VALUES (103,'B',4)
> INSERT INTO #Test(number,[name],rowid) VALUES (102,'T',0)
> INSERT INTO #Test(number,[name],rowid) VALUES (104,'a',2)
>
> SELECT [name]FROM #Test
> WHERE rowid=(SELECT MIN(rowid) FROM #Test T WHERE T.number=#Test.number)
>
>
> "Bernie Yaeger" <berniey@.optonline.net> wrote in message
> news:eN$erwlkFHA.1384@.TK2MSFTNGP10.phx.gbl...
>|||Hi Aaron,
Tx so much for your help.
Bernie
"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:ORACDEmkFHA.708@.TK2MSFTNGP10.phx.gbl...
> You're looking for a correlated subquery.
>
> CREATE TABLE #foo
> (
> rowid INT IDENTITY(1,1),
> [name] VARCHAR(12),
> [number] INT
> )
> SET NOCOUNT ON
> INSERT #foo([name], [number]) SELECT 'bob', 102
> INSERT #foo([name], [number]) SELECT 'allen', 102
> INSERT #foo([name], [number]) SELECT 'carl', 104
> INSERT #foo([name], [number]) SELECT 'mike', 104
> SELECT [name],[number],rowid
> FROM #foo f1
> WHERE rowid = (SELECT MIN(rowid)
> FROM #foo f2
> WHERE f2.[number] = f1.[number])
> ORDER BY [number]
> DROP TABLE #foo
>
>
> "Bernie Yaeger" <berniey@.optonline.net> wrote in message
> news:eN$erwlkFHA.1384@.TK2MSFTNGP10.phx.gbl...
>

Returning the next identity value before writing a record.

I am storing product information in a SQL Server database table; the product information has no unique fields so I have created an Identity field called 'uid'. Is there a way of querying the table to find out what value will be given to the next 'uid' field before the next record is written to the table? I need to use this as a FK in other tables.There is not any safe way of doing that. You can query the table for the current highest number, but that will fail when multiple users are hitting the database.
Insert the new row and the related rows in a transaction, or add a "Pending" flag to the table, and have it default to True (meaning it is pending) and then have other parts of the system look for Pending==false rows.|||you can change the data type to uniqueidentifier, that way you'll knowthe id of that row since you'll be passing it a Guid that you create.
|||

In SQL Server GUID is a 16bytes binary data type, run a search for NEWID in the BOL (books online) and another option is DBCC CHECKIDENTITY. Try the link below for DBCC CHECKIDENTITY. Hope this helps.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_dbcc_5lv8.asp