[SMO SQL Server 2005] Drop login

  • Hi,

    When I try to delete a login using smo, I have an error :

    Drop failed for Login myLogin

    This is what I do :

    Dim log As New Login(myServer, myLogin)

    If myServer.Logins.Contains(myLogin) Then

    log.Drop()

    End If

    When I try to rename or change password for this Login, I obtain the same message.

    Thanks

  • I suspect that whatever connection you are using lacks the necessary permissions to administer logins. You could try to use trace/profiler to see what SMO is attempting to do in SQL Server.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Thank you for your answer but I've found out!

    I have to delete the schema and database users for the login first and replace Dim log As New Login(myServer, myLogin)

    If myServer.Logins.Contains(myLogin) Then

    Dim log As Login = myServer.Logins(myLogin)

    If Not (log Is Nothing) Then log.Drop()

    End If

  • Tasumy (3/11/2009)


    Thank you for your answer but I've found out!

    I have to delete the shema and database users for the login first and replace Dim log As New Login(myServer, myLogin)

    If myServer.Logins.Contains(myLogin) Then

    Dim log As Login = myServer.Logins(myLogin)

    If Not (log Is Nothing) Then log.Drop()

    End If

    Well, that is true if you try to DROP the login, but that should not have any effect on changing the password?

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • What do you mean "on changing the password"?

    I don't need to change it.

  • From your original post:

    Tasumy (3/10/2009)


    When I try to rename or change password for this Login, I obtaine the same message.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Right. Sorry.

    I'll try tomorrow.

    Thanks

  • To change a password :

    Dim log As Login = myServer.Logins(myLogin)

    log.ChangePassword(myPwd)

    instead of

    Dim log As New Login(myServer, myLogin)

    log.ChangePassword(myPwd)

    Of course, the login has not to be "nothing".

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply