September 3, 2007 at 9:17 am
Hi all,
I'm running into a bit of an issue with the is_member function in SQL Server 2000.
I've created a user account, and a database role ('fcc_admin'). I've added the user to the role, but when I log in to Query Analyzer as the user, and run 'print is_member('fcc_admin')', it returns 0.
Has anyone else encountered a similar issue? If so how did you resolve it?
thanks,
Marcus
September 4, 2007 at 12:38 am
keep in mind you need to be connected with that user and to the correct database.
Overhere it works fine (sql2000 sp4 + CU(2187))
Did you also try sp_helprolemember @rolename = 'testrole'
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
September 4, 2007 at 4:23 am
Hi,
I tried using sp_helprolemember, and it shows my user id as being in the role, however is_member is still not working.
September 4, 2007 at 4:26 am
looks like the image isn't showing so here is what I see in query analyzer (I am logged in as user malinowm2)
query pane :
select is_member('fcc_admin') as [is_member]
go
sp_helprolemember @rolename = 'fcc_admin'
results pane:
is_member
-----------
0
(1 row(s) affected)
DbRole MemberName MemberSID
-------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
fcc_admin batch 0x0713C0CF09356442A11F4CF936847CDC
fcc_admin dtjiook 0xB068EC1003FE8F409C6CA11C9BE505B3
fcc_admin hgodfrey 0xA8FD904BECE16A46BBD7EEB4E8EA9491
fcc_admin hthandi 0x08E17F9952D7F94DA3877E662ACC9CE2
fcc_admin malinowm1 0x63D5B843BB48E243A8B43C19FE6F9987
fcc_admin malinowm2 0x5CE33E5968DCA740A07FCCE7B5655E93
(6 row(s) affected)
September 4, 2007 at 4:41 am
can you execute the same script preceded by :
select user_id() as UID
, user_name() as Uname
select SUSER_SID ( ) SUSID
, suser_sname() as SUname
go
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
September 4, 2007 at 4:53 am
ok, so i ran these commands:
select user_id() as UID, user_name() as Uname
select suser_sname() as SUname
go
select is_member('fcc_admin') as [is_member]
go
sp_helprolemember @rolename = 'fcc_admin'
and this is what i got in my results pane:
UID Uname
------ --------------------------------------------------------------------------------------------------------------------------------
1 dbo
(1 row(s) affected)
SUname
--------------------------------------------------------------------------------------------------------------------------------
malinowm2
(1 row(s) affected)
is_member
-----------
0
(1 row(s) affected)
DbRole MemberName MemberSID
-------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
fcc_admin batch 0x0713C0CF09356442A11F4CF936847CDC
fcc_admin dtjiook 0xB068EC1003FE8F409C6CA11C9BE505B3
fcc_admin hgodfrey 0xA8FD904BECE16A46BBD7EEB4E8EA9491
fcc_admin hthandi 0x08E17F9952D7F94DA3877E662ACC9CE2
fcc_admin malinowm1 0x63D5B843BB48E243A8B43C19FE6F9987
fcc_admin malinowm2 0x5CE33E5968DCA740A07FCCE7B5655E93
(6 row(s) affected)
Should I be seeing 'malinowm2' when querying user_name()?
September 4, 2007 at 6:51 am
UID Uname
------ ------
1 dbo
means your current user _is_ the database owner !
(if he were member of db_owner, it would still show the actual username)
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
September 4, 2007 at 7:36 am
ok, i've tried this out with a couple of other logins, both of whom are members of the fcc_admin group.
I also get the same results for the 'select user_id() as UID, user_name() as Uname' query. Looking in enterprise manager, all the user id's I've tried are mapped to login names which are the same as their name. e.g. malinowm2 in my database is mapped to a sql id called malinowm2.
To be honest my understanding of sql security is limited, but it looks like all these users are the database owner?
September 4, 2007 at 7:53 am
can you also try :
select user_id('malinowm2')
?
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
September 4, 2007 at 7:57 am
Yeah that returns 13 as my user_id.
I've tried deleting the user and recreating through enterprise manager, assigning to roles etc., same result though.
Thanks for your help with this by the way!
September 4, 2007 at 8:15 am
.. Thanks for your help with this by the way! ..
That's the strength of forums like SSC
Like you do, I find your results strange
Can you test this scenario ?
/****** Object: Database test Script Date: 04/09/2007 16:10:46 ******/
CREATE DATABASE [test]
GO
use [test]
GO
/****** Object: Login test Script Date: 04/09/2007 16:10:46 ******/
if not exists (select * from master.dbo.syslogins where loginname = N'test')
BEGIN
declare @logindb nvarchar(132), @loginlang nvarchar(132) select @logindb = N'test', @loginlang = N'us_english'
if @logindb is null or not exists (select * from master.dbo.sysdatabases where name = @logindb)
select @logindb = N'master'
if @loginlang is null or (not exists (select * from master.dbo.syslanguages where name = @loginlang) and @loginlang <> N'us_english')
select @loginlang = @@language
exec sp_addlogin N'test', 'verystrongpassword', @logindb, @loginlang
END
GO
/****** Object: User test Script Date: 04/09/2007 16:10:46 ******/
if not exists (select * from dbo.sysusers where name = N'test')
EXEC sp_grantdbaccess N'test', N'test'
GO
/****** Object: Table [dbo].[t_test] Script Date: 04/09/2007 16:10:47 ******/
CREATE TABLE [dbo].[t_test] (
[test] [char] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
/*
-- to be executed in a new connection using SQLUser test with its password
select user_id() as UID
, user_name() as Uname
select user_id('test')
select user_name(user_id('test'))
This gives me :
UID Uname
------ ---------
5 test
(1 row(s) affected)
------
5
(1 row(s) affected)
----
test
(1 row(s) affected)
*/
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
September 4, 2007 at 8:23 am
I tried that out and got slightly different results to you. I used a windows account, and also a sql account (malinowm2). My results were the same for both users and were:
The CREATE DATABASE process is allocating 0.63 MB on disk 'test'.
The CREATE DATABASE process is allocating 0.49 MB on disk 'test_log'.
Granted database access to 'test'.
UID Uname
------ --------------------------------------------------------------------------------------------------------------------------------
1 dbo
(1 row(s) affected)
------
5
(1 row(s) affected)
--------------------------------------------------------------------------------------------------------------------------------
test
(1 row(s) affected)
September 4, 2007 at 2:24 pm
Does the userid 'malinowm2' have database owner permissions on the database? This could be automatically mapping you to 'dbo'.
Steve G.
September 5, 2007 at 2:36 am
>>Does the userid 'malinowm2' have database owner permissions on the database? This could be automatically mapping you to 'dbo'.
No, the user has membership of several database roles, 'public', 'fcc_admin', and a couple more user defined roles. It also has membership of the 'system administrators' and 'security administrators' server roles.
September 5, 2007 at 2:44 am
Steve,
thanks for your post. I think it's helped me get a bit closer to finding the source of this problem.
I tried out removing 'malinowm2' from the system administrators group, and all of a sudden is_member('fcc_admin') is working. This is unfortunate as I really wanted the user to be a sysadmin so that I could use the SETUSER command so I could run jobs as another user.
If I recall correctly there's another way of getting the necessary permissions to run SETUSER so I'll try that out.
Marcus
Viewing 15 posts - 1 through 15 (of 18 total)
You must be logged in to reply to this topic. Login to reply