addlogin Issues

  • We have a script that creates a server login, then a database, then associates/creates a database user between the server login and newly created DB as such:

    EXEC sp_addlogin @loginame = @LoginName ,@passwd = @Password ,@defdb = 'master'

    SET @SQL = 'CREATE DATABASE ' + @Database

    EXEC (@SQL)

    SET @SQL = 'USE ' + @Database + ';' + ' CREATE USER ' + @LoginName + ' FOR LOGIN ' + @LoginName + ' WITH DEFAULT_SCHEMA=[dbo]'

    EXEC (@SQL)

    I omitted all of the IF NOT EXISTS for clarity

    Now, the problem we are having is that if the server is set up to enforce password policies, this login cannot login (Login = Denied) and Enforce password policy is checked.

    My question is, how can I make it to where Status --> Login is set to Enabled and General --> Enforce password policy is unchecked (as well as the other two Enforce password expiration and User must change password at next login)?

    Thank you in advance,

    Jim

  • You may have to write your own procedure using the CREATE LOGIN statement. Looking at the sp_addlogin in BOL doesn't show anyway of doing what you are asking.

Viewing 2 posts - 1 through 1 (of 1 total)

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