Showing posts with label password. Show all posts
Showing posts with label password. Show all posts

Thursday, March 8, 2012

Create new login non case sensitive

I am trying to create a new login on a database, and I want that username and password NOT to be case sensitive. Do I have to set this at the server level or can I set this in the SQL script?

Here is the script I am currently using...

IF EXISTS (SELECT * FROM dbo.sysusers WHERE [name] = 'UName')

BEGIN

EXEC sp_dropuser 'UserName'

EXEC sp_droplogin 'UserName'

END

EXEC sp_addlogin 'UserName', 'Password', 'Database'

GO

EXEC sp_adduser 'UserName', 'Password', 'db_datareader'

GO

Any help would be appreciated...

David

SQL Server 2005 only uses case sensitive password, this is an intentional behavior change for SQL Server 2005.See http://msdn2.microsoft.com/en-us/library/ms143359.aspx for more details.

Thanks,

-Raul Garcia

SDE/T

SQL Server Engine

|||

Also, the sp_adduser statement is incorrect - there is no password for users; the second parameter of sp_adduser is the user's name in the database. See http://msdn2.microsoft.com/en-us/library/ms181422.aspx for more information on sp_adduser.

Thanks
Laurentiu

Wednesday, March 7, 2012

Create Logon

Newbie question
Following script works OK against a SQL Server 2005
CREATE LOGIN [LoginX] WITH PASSWORD = 'PasswordX',DEFAULT_DATABASE=[DBX]
But against a SQL Server 2000 I get "Incorrect syntax near 'LOGIN'."
How do I change the script to work for 2000?
/BroedenBroeden wrote:
> Newbie question
> Following script works OK against a SQL Server 2005
> CREATE LOGIN [LoginX] WITH PASSWORD => 'PasswordX',DEFAULT_DATABASE=[DBX]
> But against a SQL Server 2000 I get "Incorrect syntax near 'LOGIN'."
> How do I change the script to work for 2000?
> /Broeden
>
look in BOL for sp_addlogin:
sp_addlogin [ @.loginame = ] 'login'
[ , [ @.passwd = ] 'password' ]
[ , [ @.defdb = ] 'database' ]
[ , [ @.deflanguage = ] 'language' ]
[ , [ @.sid = ] sid ]
[ , [ @.encryptopt= ] 'encryption_option' ]

Create Login within a stored procedure

I want to create a login from within a stored procedure; passing in a
User name and a password.
It keeps giving me an error when I use a variable as the password.
what am I doing wrong?
CREATE LOGIN [@.aUserName] WITH PASSWORD= [@.aPassword]One hint.
Square brackets have the same effect as single quotes.
Arnie Rowland*
"To be successful, your heart must accompany your knowledge."
"Jayme" <jayloub@.comcast.net> wrote in message
news:1152628773.520426.185450@.s13g2000cwa.googlegroups.com...
>I want to create a login from within a stored procedure; passing in a
> User name and a password.
> It keeps giving me an error when I use a variable as the password.
> what am I doing wrong?
>
> CREATE LOGIN [@.aUserName] WITH PASSWORD= [@.aPassword]
>|||Unfortunately, CREATE LOGIN doesn't accept parameters so you need to use
dynamic SQL. The example uses QUOTENAME to properly enclose the values and
handle embedded quotes.
CREATE PROC dbo.usp_CreateLogin
@.Login sysname,
@.Password sysname
AS
DECLARE @.CreateLoginStatement nvarchar(200)
SET @.CreateLoginStatement = 'CREATE LOGIN ' +
QUOTENAME(@.Login) +
' WITH PASSWORD = ' +
QUOTENAME(@.Password, '''')
EXEC sp_executesql @.CreateLoginStatement
GO
Hope this helps.
Dan Guzman
SQL Server MVP
"Jayme" <jayloub@.comcast.net> wrote in message
news:1152628773.520426.185450@.s13g2000cwa.googlegroups.com...
>I want to create a login from within a stored procedure; passing in a
> User name and a password.
> It keeps giving me an error when I use a variable as the password.
> what am I doing wrong?
>
> CREATE LOGIN [@.aUserName] WITH PASSWORD= [@.aPassword]
>|||Thanks, that worked.
Dan Guzman wrote:[vbcol=seagreen]
> Unfortunately, CREATE LOGIN doesn't accept parameters so you need to use
> dynamic SQL. The example uses QUOTENAME to properly enclose the values an
d
> handle embedded quotes.
> CREATE PROC dbo.usp_CreateLogin
> @.Login sysname,
> @.Password sysname
> AS
> DECLARE @.CreateLoginStatement nvarchar(200)
> SET @.CreateLoginStatement = 'CREATE LOGIN ' +
> QUOTENAME(@.Login) +
> ' WITH PASSWORD = ' +
> QUOTENAME(@.Password, '''')
> EXEC sp_executesql @.CreateLoginStatement
> GO
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Jayme" <jayloub@.comcast.net> wrote in message
> news:1152628773.520426.185450@.s13g2000cwa.googlegroups.com...

Create Login within a stored procedure

I want to create a login from within a stored procedure; passing in a
User name and a password.
It keeps giving me an error when I use a variable as the password.
what am I doing wrong?
CREATE LOGIN [@.aUserName] WITH PASSWORD= [@.aPassword]One hint.
Square brackets have the same effect as single quotes.
--
Arnie Rowland*
"To be successful, your heart must accompany your knowledge."
"Jayme" <jayloub@.comcast.net> wrote in message
news:1152628773.520426.185450@.s13g2000cwa.googlegroups.com...
>I want to create a login from within a stored procedure; passing in a
> User name and a password.
> It keeps giving me an error when I use a variable as the password.
> what am I doing wrong?
>
> CREATE LOGIN [@.aUserName] WITH PASSWORD= [@.aPassword]
>|||Unfortunately, CREATE LOGIN doesn't accept parameters so you need to use
dynamic SQL. The example uses QUOTENAME to properly enclose the values and
handle embedded quotes.
CREATE PROC dbo.usp_CreateLogin
@.Login sysname,
@.Password sysname
AS
DECLARE @.CreateLoginStatement nvarchar(200)
SET @.CreateLoginStatement = 'CREATE LOGIN ' +
QUOTENAME(@.Login) +
' WITH PASSWORD = ' +
QUOTENAME(@.Password, '''')
EXEC sp_executesql @.CreateLoginStatement
GO
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Jayme" <jayloub@.comcast.net> wrote in message
news:1152628773.520426.185450@.s13g2000cwa.googlegroups.com...
>I want to create a login from within a stored procedure; passing in a
> User name and a password.
> It keeps giving me an error when I use a variable as the password.
> what am I doing wrong?
>
> CREATE LOGIN [@.aUserName] WITH PASSWORD= [@.aPassword]
>|||Thanks, that worked.
Dan Guzman wrote:
> Unfortunately, CREATE LOGIN doesn't accept parameters so you need to use
> dynamic SQL. The example uses QUOTENAME to properly enclose the values and
> handle embedded quotes.
> CREATE PROC dbo.usp_CreateLogin
> @.Login sysname,
> @.Password sysname
> AS
> DECLARE @.CreateLoginStatement nvarchar(200)
> SET @.CreateLoginStatement = 'CREATE LOGIN ' +
> QUOTENAME(@.Login) +
> ' WITH PASSWORD = ' +
> QUOTENAME(@.Password, '''')
> EXEC sp_executesql @.CreateLoginStatement
> GO
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Jayme" <jayloub@.comcast.net> wrote in message
> news:1152628773.520426.185450@.s13g2000cwa.googlegroups.com...
> >I want to create a login from within a stored procedure; passing in a
> > User name and a password.
> > It keeps giving me an error when I use a variable as the password.
> > what am I doing wrong?
> >
> >
> > CREATE LOGIN [@.aUserName] WITH PASSWORD= [@.aPassword]
> >

Create login account

I have installed MSDE 2000 on my computer. When I try to use ODBC to connect
to the data source, it keeps asking me to enter User Name and Password. Can
someone please tell me how I can create an account to connect to the SQL data
source?
> I have installed MSDE 2000 on my computer. When I try to use ODBC to
connect
> to the data source, it keeps asking me to enter User Name and Password.
Can
> someone please tell me how I can create an account to connect to the SQL
data
> source?
Here is a good starting point for MSDE security:
http://support.microsoft.com/default...;en-us;325022.
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com

Friday, February 17, 2012

Create database with username and password

Hello!

I can't figure it out how to create a database with an username and a password. I'm using Visual Studio 2005 and Microsoft SQL Server 2005.

Can someone help me out?Big Smile

Greetings,
Persyn Bert.

u need to use CREATE LOGIN & CREATE USER....for more check

http://msdn2.microsoft.com/en-us/library/ms173463.aspx

also,i think need to go thru the SQL server security model once...

http://www.developer.com/tech/article.php/721441

.....its an old article but still will gv a very clear picture

|||

Hello Imran Nathani!

Thank you for responding, but I what I really want to know is how tosecure a database with a username and password, not creating users in a table of a database.

Greetings
Persyn Bert

|||i think thats what i have given...............|||

OopsEmbarrassed, I'm very sorry...

Where do I past the code for execution?

Greetings
Persyn Bert

|||they can be excuted in the query analyzer....can be executed from code behind...they are to be treated as queries (CREATE is an SQL clause)|||

I appreciate your help!

Greetings
Persyn Bert