acctpolicy.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /******************************************************************************
  2. Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. version 2 as published by the Free Software Foundation.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  13. Contributors:
  14. Hewlett-Packard Development Company, L.P.
  15. ******************************************************************************/
  16. #include <limits.h> /* ULONG_MAX */
  17. #include "nspr.h"
  18. #define SLAPI_OP_FLAG_BYPASS_REFERRALS 0x40000
  19. #define CFG_LASTLOGIN_STATE_ATTR "stateAttrName"
  20. #define CFG_ALT_LASTLOGIN_STATE_ATTR "altStateAttrName"
  21. #define CFG_SPEC_ATTR "specAttrName"
  22. #define CFG_INACT_LIMIT_ATTR "limitAttrName"
  23. #define CFG_RECORD_LOGIN "alwaysRecordLogin"
  24. #define DEFAULT_LASTLOGIN_STATE_ATTR "lastLoginTime"
  25. #define DEFAULT_ALT_LASTLOGIN_STATE_ATTR "createTimestamp"
  26. #define DEFAULT_SPEC_ATTR "acctPolicySubentry"
  27. #define DEFAULT_INACT_LIMIT_ATTR "accountInactivityLimit"
  28. #define DEFAULT_RECORD_LOGIN 1
  29. #define PLUGIN_VENDOR "Hewlett-Packard Company"
  30. #define PLUGIN_VERSION "1.0"
  31. #define PLUGIN_CONFIG_DN "cn=config,cn=Account Policy Plugin,cn=plugins,cn=config"
  32. #define PLUGIN_NAME "acct-policy"
  33. #define PLUGIN_DESC "Account Policy Plugin"
  34. #define PRE_PLUGIN_NAME "acct-policy-preop"
  35. #define PRE_PLUGIN_DESC "Account Policy Pre-Op Plugin"
  36. #define POST_PLUGIN_NAME "acct-policy-postop"
  37. #define POST_PLUGIN_DESC "Account Policy Post-Op Plugin"
  38. #define CALLBACK_OK 0
  39. #define CALLBACK_ERR -1
  40. #define CALLBACK_HANDLED 1
  41. typedef struct acct_plugin_cfg {
  42. char* state_attr_name;
  43. char* alt_state_attr_name;
  44. char* spec_attr_name;
  45. char* limit_attr_name;
  46. int always_record_login;
  47. unsigned long inactivitylimit;
  48. } acctPluginCfg;
  49. typedef struct accountpolicy {
  50. unsigned long inactivitylimit;
  51. } acctPolicy;
  52. /* acct_util.c */
  53. int get_acctpolicy( Slapi_PBlock *pb, Slapi_Entry *target_entry,
  54. void *plugin_id, acctPolicy **policy );
  55. void free_acctpolicy( acctPolicy **policy );
  56. int has_attr( Slapi_Entry* target_entry, char* attr_name,
  57. char** val );
  58. char* get_attr_string_val( Slapi_Entry* e, char* attr_name );
  59. void* get_identity();
  60. void set_identity(void*);
  61. time_t gentimeToEpochtime( char *gentimestr );
  62. char* epochtimeToGentime( time_t epochtime );
  63. /* acct_config.c */
  64. int acct_policy_load_config_startup( Slapi_PBlock* pb, void* plugin_id );
  65. acctPluginCfg* get_config();