Search code examples
sap-asedatabase-security

Report on individual password expiration intervals in Sybase ASE 12.5


I want to run a report to make sure the password of every user is set to expire every 30 days, but the expiration interval doesn't seem to be stored in syslogins?


Solution

  • you can get report with following proc:

    use sybsystemprocs
    go
    ----------------------------------------------------------------------------
    print 'sp__helpexpire'
    ----------------------------------------------------------------------------
    if exists (select 1 from sysobjects where  type = "P" and  name = "sp__helpexpire")
            drop proc sp__helpexpire
    go
    create procedure sp__helpexpire
    as
    begin
      set nocount on
      declare @swexpire int
      select @swexpire=value from master.dbo.sysconfigures
        where name = 'systemwide password expiration'
      print "Serverwide password expire: %1!" ,@swexpire
      print ""
      print "Logins:"
      print "=============================================================="
      select l.name login , case a.int_value
          when null then @swexpire
          else a.int_value end "expire in days"
        from master.dbo.syslogins l , master.dbo.sysattributes a
        where l.suid *= a.object
          and a.object_type='PS'
          and a.attribute=0
          and object_cinfo='login'
      print ""
      print "Roles:"
      print "=============================================================="
      select r.name "role name", case a.int_value
          when null then @swexpire
          else a.int_value end "expire in days"
        from master.dbo.syssrvroles r , master.dbo.sysattributes a
        where r.srid *= a.object
          and a.object_type='PS'
          and a.attribute=0
          and object_cinfo='role'
    end
    go
    

    it is always a good idea to check source code of those system procedures (stored in sybsystemprocs database) which manipulate with records you are looking for (in this case it is sp_addlogin, sp_modifylogin)