Re: Login/User modification from an application?



No...it's because DROP LOGIN itself doesn't accept
parameters and that's what you are asking it to do. You
would need to use dynamic SQL but you really would want to
read the following first:
http://www.sommarskog.se/dynamic_sql.html

So for the stored procedure you posted to work, one option
would be to dynamically build the statement and pass it into
an EXEC.
So instead of the line:
Drop Login [@LoginName]
you would use something like:
EXEC('DROP LOGIN ' + @LoginName)

-Sue

On Mon, 25 Sep 2006 13:31:01 -0700, Greg P.
<GregP@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

I have an application and I want to add/edit/del Logins and Users in Sql
Server 2005 through the application, can I do it? I am using windows
authentication. Currently I call a stored proc that I try to pass a login
and it doesn't work. For example this is my Delete.

ALTER PROCEDURE [dbo].[usp_UserRoleDelete]
-- Add the parameters for the stored procedure here
@LoginName nvarchar(50)
AS
BEGIN

SET NOCOUNT ON;
Begin
--Drop the login which drops the user?
Drop Login [@LoginName]

End
END

When it runs I get you can't add a login called @LoginName. If I take the
brackets off it will not compile. Can i do what I'm trying to do? I've also
tried using sp_DropLogin w/o success. I did see somewhere in documentation
for the sp_dropLogin "sp_droplogin cannot be executed within a user-defined
transaction." There is nothing about the in the Drop Login documentation.
Is this the problem?

Thanks in advance,
Greg P.

.



Relevant Pages

  • Re: [PHP] access to DB and security
    ... If i use this login + password to connect and perform some actions ... only execute some stored procedure but can not administrate my DB. ... One is to switch to a host, perhaps a dedicated host, where you DO ... business process and authentication model looks like... ...
    (php.general)
  • Re: Limiting views on data in a table
    ... >returns the Windows login the user uses to connect to SQL Server. ... >use it in the WHERE clause of your single stored procedure for everybody to ... pass the login name as a parameter in the stored procedure). ...
    (microsoft.public.sqlserver.security)
  • Re: Drop Merge Pull Subscription at Publisher?
    ... when a login who is in the PAL has the permission ... login call sp_dropmergesubscription also on the Publisher. ... > information of where this stored procedure should be run at and there will ...
    (microsoft.public.sqlserver.replication)
  • Re: SQL Connection help needed
    ... Have your DB Admin give your NT login access to the stored procedure ... Here is my current connection string that is using my own NT login: ... I have access to this database and the connection establishes fine. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Creating Customer Web Portal
    ... Roles and Profiles system that integrates with the database ... which a stored procedure builds for us. ... I want a simple login page with username and password. ...
    (microsoft.public.frontpage.addins)