SHARE
TWEET

Untitled

a guest Feb 18th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. select
  2.     @@SERVERNAME as servername,
  3.     name,
  4.     IS_SRVROLEMEMBER('sysadmin', name) as SYSADMIN,
  5.     type_desc,
  6.     create_date,
  7.     is_policy_checked,
  8.     is_disabled,
  9.     password_hash,
  10.     PWDCOMPARE(name, password_hash) as UsernameAsPassword
  11. FROM sys.sql_logins
  12.    
  13. SELECT N'ALTER LOGIN ' + QUOTENAME(name)
  14.   + N' WITH PASSWORD = N'''' MUST_CHANGE, CHECK_POLICY = ON;'
  15.   FROM sys.sql_logins
  16.   --WHERE is_policy_checked = 0;
  17.    
  18. SELECT N'BEGIN TRY
  19.   CREATE LOGIN ' + QUOTENAME(N'copy_of_' + name)
  20.     + N' WITH PASSWORD = '
  21.     + CONVERT(NVARCHAR(255), password_hash, 1)
  22.     + ' HASHED, CHECK_POLICY = ON;
  23.   DROP LOGIN ' + QUOTENAME(N'copy_of_' + name) + ';
  24. END TRY
  25. BEGIN CATCH
  26.   IF ERROR_NUMBER() = 15118
  27.     PRINT N''' + REPLACE(name, '''', '''''')
  28.       + N' was not complex enough.'';
  29. END CATCH'
  30. FROM sys.sql_logins;
  31.    
  32. SELECT name,
  33. create_date,
  34. modify_date,
  35. LOGINPROPERTY(name, 'DaysUntilExpiration') DaysUntilExpiration,
  36. LOGINPROPERTY(name, 'PasswordLastSetTime') PasswordLastSetTime,
  37. LOGINPROPERTY(name, 'IsExpired') IsExpired,
  38. LOGINPROPERTY(name, 'IsMustChange') IsMustChange
  39. From sys.sql_logins ;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top