Changing The LoginName Of A User

Aug 8, 2007



I'm trying to automate the creation of a databse and a User/Login but i'm running into problem with a conflict between a new user to which i'm trying to assign a WindowsLogin which is already linked to the dbo. (SQL Server 2005)

Is there a way to reassign the dbo's LoginName to some othe user


Here the code

IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'ABC')
BEGIN
declare @cmd nvarchar(max)
set @cmd = 'CREATE USER [ABC] FOR LOGIN ' + @WindowsLogin + ' WITH DEFAULT_SCHEMA=[Shared]'
exec(@cmd)
END

Which give me the error

Msg 15063, Level 16, State 1, Server SR-DEV-GOI1, Line 1
The login already has an account under a different user name.

The script is running under the @WindowsLogin in question !

Thanks All
Gilbert

View 2 Replies


ADVERTISEMENT

How To Create A User With Name Dbo And Loginname KING

Sep 10, 2004

How to create a user with name dbo and loginname KING.
So that When I open Users Tab in the database, it should read Name as dbo and lOGIN AS king

View 1 Replies View Related

Using LoginName Value In SqlDataSource Query

Mar 30, 2007

I have set up roles in my asp.net application, have created my various folders and pages and have the login stuff working nicely, inlcuding displaying the logged-in user's name on screen.  What I want to do is read that value (displayed via the LoginName control) as a Parameter in a SqlDataSource query which extracts user-specific data from a sql server 2k datasource.  Essentially, if the logged-in user's UserName is jbloggs - I would like to be able to read that into my sql query as @UserName or the like.
If possible, I am trying to do this via the Visual Studio interface, not as code-behind.
 Many thanks,
 Doc Brown.

View 2 Replies View Related

Passing LoginName Into SQL Query

Mar 4, 2006

How do I pass the user’s LoginName into the WHERE clause of a SQL query?
 
I created the following query, but I don’t know how to get the user’s LoginName and pass its value into Param1. Nothing I try works.
 
SELECT property.propertyid, property.shortdesc, property.shortdesclink, property.text, property.UserID, [User].UserID AS Expr1, [User].Name FROM property INNER JOIN [User] ON property.UserID = [User].UserID WHERE ([User].Name = @Param1)

View 1 Replies View Related

Replace LoginName Control With Other Data Fields From Aspnetdb.mdf

Nov 12, 2007

I currently have a LoginStatus and LoginName control on my asp.net 2.0 master page.  When successfully logged in a message displays "You are logged in as" LoginName.  Since I am using the user's e-mail address as the UserName the message will display as "You are logged in as johndoe@foo.com".
What I want to do is have the message display as "You are logged in as " FirstName LastName.  FirstName and LastName are two new fields that I added to the table, aspnet_Users.
What I have done is to use the FormView control to display FirstName and LastName; however this always displays the first record in the aspnetdb database.
Is there a cleaner way (than the FormView control) to display the requested data, using the currently logged in user?  I have access to Microsoft Expression Web and Visual Studio 2005, but I prefer Expression Web.
Thank you in advance

View 1 Replies View Related

Changing SID Of A USER

Nov 1, 2006

Hello can anybody out there help.

I am just getting ready to move a system to production using SQL 2005 and SQL Mirroring. The problem that i have is when the databases fails over my connection string user account losses its rights on the DB untill i run the SP_CHANGE_USERS_LOGIN script. I have been trying to come up with a method of getting around this so far the only fix that i have is to make my user account sysadmin but this is far from ideal for production, does anyone have any ideas i was thinking that changing the SID of the User so that they match might get over the problem.



Any help will be good



Matt.

View 3 Replies View Related

User Changing Password

Jul 7, 2000

Can the user change their password in Enterprise Manager? When they follow the documentation, this does not seem to work
unless they are sa: (I know about sp_password....we are trying to find a GUI method for typical user.)

Expand a server group; then expand a server.
Expand Security; then click Logins.
In the details pane, right-click the login to modify, and then click Properties.
In Password, on the General tab, enter a new password.
Confirm the password.

View 2 Replies View Related

Changing User Domain

Feb 12, 2001

My SQL servers are using integrated windows nt security. Our user account is changing to a new domain. Is there an easy way to change the server logins to point to the new domain instead of removing the user and adding a new login from the new domain.

View 1 Replies View Related

Prevent User From Changing Password

Apr 17, 2011

Is there a way to prevent a particular user with SQL login from changing their password?

We have an application where we only want to prevent a certain user from changing their password but do not want to use windows authentication?

View 14 Replies View Related

Changing The Domain User Password

Apr 8, 2004

Is there an automatic way of changing the Domain user password getting used for running the SQL Server as a Domain user account? I'm taking about EM---Security----Domain User name and the password getting used for running the SQL Server?

View 1 Replies View Related

Changing User Accound And Password

Oct 15, 2007



I tried to cahnge this account option to built in account option in SQL ( MSSQLSERVER) properties box. Then SQL Server was log on as Local system. But then I can not view my reports which i created. Now I changed it again to this account option. but I dont exaclty remember the password. Is there anyway I can get to know the password I created.

Thanks

View 1 Replies View Related

SQL Security :: How To Trace Changing On DB User

Jun 3, 2015

Is there a kind of log to trace the change on DB user, such as when the password/permission is changed, etc. If yes, how can i get this log; If no, is there a way to achieve this thing?

View 2 Replies View Related

Changing HOME Folder Per User

Jun 18, 2007

I am wondering how I could do the following -

Right now the default folder is Home, what if I have two users User1 and User2, my folder structure is the following -
Home/User1
Home/User2

I want each user to only have access to their folder. That is easy to do.

Once both users have proper access to their folders they still don't have access to Home folder. In Report Builder when I do 'open file' it defaults to Home folder so I get an error. How can I specify the home folder to be User1 for that user and User2 for the second user? I know I can give them both browsing permissions to Home but it's not very elegant.

There must be a way to programmatically change the folder as soon as proper user logs in. Anyone knows how to do that?

Thanks.

View 9 Replies View Related

Changing Owner Of User Datatype Objects

Jan 29, 2002

Usually all the user datatypes in our databases have the owner dbo.
One has a few that are owned by a user with dbo rights. I am trying to change them to dbo owner.
Sp_changeobjectowner gives 'object does not exist'

Any ideas

Jim

View 1 Replies View Related

Changing User Defined Data Types

Aug 24, 2000

Is there a way to change the physical mapping of a user defined data type to the physical SQL Server datatype. It seems that once you create them, it is just about impossible to change it.

Thanks,
Andrew Abrams

View 3 Replies View Related

Changing SSIS Package - New User Question

Feb 23, 2006

I saved a simple export/import package from the import/export wizard to a .dtsx file/package. Now I want to change the package to delete/truncate all of the tables before adding data. (since this has 80 tables it would have been a pain to edit each of them individually)

How can I easily go about doing this with the SSIS package. I can't find out where this would actually be executed.

Also, how can I actually view the code behind the SSIS package.

Thanks.

View 3 Replies View Related

Changing/Setting Windows User For SSIS

Feb 22, 2008

I wrote a simple SSIS package that runs a batch and a stored proc. They both run fine. I can see the stored procedure run and in process under task manager I see the batch run. However I don't want the batch to run under the System account, how can I change to another user. Thank you.

View 4 Replies View Related

Changing User Used To Execute Scheduled Jobs

Dec 19, 2005

Hello. I am using SQL Server Management Studio (SQL 2005) and created a daily backup job. Inside the job, i have an "Operating system" step to copy backuped up files onto another directory. However, the job kept on failing with an error "Executed as user ... Access is denied." With this error, how can i change the user used to execute the job? Thanks.

View 5 Replies View Related

Changing A Field's Value When User Updates Data

Sep 10, 2007

Hello,
I am working on a project that involves one part where a field's value needs to be changed when the user updates the record. Here is the situation in detail:
There is an InputData table where the user enters new records or changes existing records. There is a field called "calculated" in this table which has a default value of 'no'. A stored procedure runs math calculations on all the InputData records where the calculated field = 'no'. At the end of this stored procedure, it sets the calculated field = 'yes'. When new records are added by the user their "calculated" field value is 'no' by default so that the next time the stored procedure is executed, it only runs the math calculations on the new records. The problem is, if a user changes an existing record, the "calculated" field needs to be changed from 'yes' to 'no' so that the stored procedure recalculates the math for the modified record. How do I change the value from 'yes' to 'no' on records that the user modifies?
Thanks.

View 9 Replies View Related

Changing SQL Server Connection String Based On User.

Mar 1, 2007

I’m working with a team of programmers who are in the process of upgrading an older ASP application to ASP.NET 2.0 (VB).  The existing application connects to the SQL Server Database using different Logins, depending on the User logged into the ASP Application.
 
We are hoping to do the same using ASP.NET 2.0, although we haven’t been able to find a simple solution.  The most feasible solution we have found includes programmatically trapping all the Selecting etc events and changing the SqlConnection at run time.  This allow for ease during Designing of the Web Pages, but implementation requires adding code to each web page (>100 pages).
 
We are hoping there may be a simple solution which can be implemented once for the application where the event can be trapped at the application level, and the SqlConnection set at this point.  Or possibly another type of solution such as creating a new class etc that can be used?
 
Does anyone have a simple solution where the username / password for the Database Connection can be set at run time?

View 2 Replies View Related

Changing Ownership Of User Defined Data Types?

May 14, 2008

We have a database that originally had all objects owned by a vendor id. We are in the process of changing the ownership to 'dbo' and wish to remove the vendor id but have found there are a few user defined datatypes that are also owned by this vendor id. How can I change the ownership of them to 'dbo'? They are currently being used in some of the tables. I tried the sp_changeobjectowner but that doesn't work for these.

thanks for any advice!

View 3 Replies View Related

Changing The Owner Of A User-defined Data Type

Jul 20, 2005

Hi GuysWonder if you could help me.Basically I produce an accounts package that uses a SQL 2000 DB as theRDBMS. I always instruct users to login as 'sa' and the relevantpassword when doing an update to my program, as sometimes I need to dodatabase changes for new stuff.Found that one of my users has not only logged in with their loginname (in this case Edward), but have also made this login a 'db owner'so that when I created 2 new user-defined data types they belong toEdward rather than dbo.This must have happened a long time ago, but now that they want tomove Edward round the roles and/or delete him from a copy of thedatabase that they have, they can't because he's the owner of theseuser-defined types.This brings me to the reason for my post, how can I change the ownerfrom Edward to dbo for these data types? I found an article ontechnet of how to do this, but when it suggests changing myuser-defined type to standard format it doesn't seem to work.Any ideas?RgdsRobbie

View 1 Replies View Related

SQL Server 2008 :: Changing DB Mode From Single To Multi User

Mar 4, 2015

I have tried everything I found on Google, but nothing seems to be working. Already Ran alter command set multi_user, but getting an error.

"Msg 5064, Level 16, State 1, Line 1

Changes to the state or options of database cannot be made at this time. The database is in single-user mode, and a user is currently connected to it.

Msg 5069, Level 16, State 1, Line 1..ALTER DATABASE statement failed."

View 8 Replies View Related

SQL Server Admin 2014 :: Changing Drive Letter For System Database And User Databases

Oct 18, 2013

I have system database and user database file are present in G,H and W drive.The process is going to be - copy data from G to S, H to T, W to U. Rename G to X, H to Y and W to Z. Rename S to G, T to H and U to W. Reboot the servers. The original G, H and W will then be X, Y and Z. The old S will be the new G, old T will be H and old U will be W. My question is that after doing this whether my SQL server will start or not

View 8 Replies View Related

Failed To Generate A User Instance Of SQL Server Due To Failure In Retrieving The User's Local Application Data Path. Please Make Sure The User Has A Local User Profile On The Computer. The Connection Will Be Closed

Dec 7, 2006

This is my first time to deploy an asp.net2 web site. Everything is working fine on my local computer but when i published the web site on a remote computer i get the error "Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed" (only in pages that try to access the database)
Help pleaseee

View 3 Replies View Related

Changing User Defined Data Type's Data Type

Sep 12, 2006

Hi,



I have a user defined data type which is called DEmployeeName,

it's length is varchar(20), how do i change it into varchar(30) without droping it?

I'm using SQL server 2005.

Thanks in advance..

View 1 Replies View Related

How Do We Determine Which User Database Tables Are Mostly Retrieved By User Or Modified By User?

May 22, 2008



Hi,
Please give the T-SQL script for this ? Thanks

Shanth


View 4 Replies View Related

Generating User Instances In Sql Server Is Disabled. Use Sp_configure User Instances Enabled To Generate User Instances.

Sep 28, 2007

 When I am in Visual Studio 2005, and I try to add an SQL database, I get the following error "generating user instances in sql server is disabled. use sp_configure user instances enabled to generate user instances." I am currently using SQL server 2005 Express. What do I need to do, to create an SQL database? Thanks in advance. 

View 4 Replies View Related

Error : Cannot Open User Default Database. Login Failed. Login Failed For User 'server/user'

Nov 22, 2007



i'm using the Enterpirse library logger to write logs into a database.
When choosing connection string i choose the database i want in the "connection properties" dialog box and
push 'Test connection' button.
everything goes well.

then i open the SQL Server Management studio express and connect to the databse to check some things,
from that point on , when i push the 'Test Connection' button in the Enterprise library i get the error:


"cannot open user default database. Login failed. login failed for user My'server/MyuserName'"


even when i close the sql server manager , it is still stuck - the connection test doesn't work anymore....
it only work when i restart the computer.

why ?

View 3 Replies View Related

Cannot Open User Default Database. Login Failed For User 'NT AUTHORITYNETWORK SERVICE'

Mar 3, 2008

 Cannot open user default database. Login failed.Login failed for user
'NT AUTHORITYNETWORK SERVICE'. Description:
An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and
where it originated in the code. Exception Details:
System.Data.SqlClient.SqlException: Cannot open user default database. Login
failed.Login failed for user 'NT AUTHORITYNETWORK SERVICE'.  I have This Error When i try to log into My online web site, i have no idea how to fix it,one day it was working and the next it wasnt, is there any way to find out what database the default is and if it's either incorrect or not present change the web.config in a way that will make my system work. i have the NT Authority/Network Service in my Server Properties Permissions, its given the type login and is granted Connect SQL by sa i have 3 colder copies of the web site on my server my question is, how would i use of of these to restore the original site configuration is there a way to restore the original configuration to undo whatever it is i've done to break the system ChrisStressed 

View 3 Replies View Related

SQL Server 2012 :: Query To Find User Who Last Modified User Roles / Access?

Dec 6, 2013

I would like to know if there is a way to find out who changed a users roles/access WITHOUT using the audit function. For example, if a user account was created and given SA access then changed to read only, how can I find out who made that change? I tried searching for an answer, but kept getting no results. I'm thinking this may tie into the sys.sysusers view?

View 3 Replies View Related

[JavaScript Error] Cannot Delete User Or User's Authority In Specific Report After Install SQL SP2

Jan 23, 2007

 Hi,

I have several reports for users to view on our Intranet. After installation of SQL 2005 SP2 patch, I cannot delete user or user's authority from Report in Properties Tab. An error message was shown on the status bar. It indicated that JavaScript Error: 'Return' statement outside of function. Seems something wrong with the 'Delete' funciton in SQL 2005 after update. The other functions worked fine. Could you point me out how to fix it or need to install any updates / hotfix. Thanks a lot!

Regards,

Kenneth Lai
Programmer


Error Pic


Message Box

 

View 1 Replies View Related

Second User Trying To Connect Generates: Cannot Open User Default Database. Login Failed.

Apr 25, 2007

Hi, I'm new to SQL Express 2005.
I found information regarding : "Cannot open user default database. Login failed."on this forum but I think that in my case it's a bit different issue.
I have a website (ASP.NET 2.0) accessing DB, in the mean time Windows Service tries to update some data in the same DB (Service runs as NT AUTHORITYLOCAL SYSTEM). The second connection is rejected: "Cannot open user default database. Login failed.Login failed for user ....".
Problem occurs only when both: service and website are running at the same time. So service and website are running without problems when they are connecting DB exclusively.
My connection string is:
"Data Source=.SQLEXPRESS;AttachDbFilename="|DataDirectory|spider-lab.mdf";Integrated Security=True;User Instance=True"

I would be grateful if you can help me

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved