sa_help_rev.erse.sa.login

  • Comments posted to this topic are about the item sa_help_rev.erse.sa.login

  • why not just use the system function fn_varbintohexstr()

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Perry,

    The answer is quite simple. I knew sp_help_revlogin already did something similar to what I needed. As I cracked into it to find out what it was doing I found it easier to whittle it down to do what I needed. As I mentioned I was on a time crunch to change those passwords for security compliance reasons, so I went with the simplest path for me at the time. I would love to see other ways to accomplish this task. I am unfamiliar with the fn_varbintohexstr function, but I will look into how it works. If you have an example to kick start my learning process it would be much appreciated. 🙂

  • Sure, here you go

    SELECT 'CREATE LOGIN ' + name +

    ' WITH PASSWORD = ' + sys.fn_varbintohexstr(password_hash) +

    ' HASHED, SID = ' + sys.fn_varbintohexstr(sid) +

    ', DEFAULT_DATABASE = ' + QUOTENAME(default_database_name) +

    ', DEFAULT_LANGUAGE = ' + default_language_name +

    ', CHECK_EXPIRATION = ' +

    CASE

    WHEN is_expiration_checked = 0 THEN 'OFF'

    ELSE 'ON'

    END + ', CHECK_POLICY = ' +

    CASE

    WHEN is_policy_checked = 0 THEN 'OFF'

    ELSE 'ON'

    END

    FROM sys.sql_logins

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

Viewing 4 posts - 1 through 3 (of 3 total)

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