home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / dn511.exe / DSAUDIT.CPP < prev    next >
Text File  |  1995-01-09  |  9KB  |  289 lines

  1. /*
  2. **    Copyright ⌐ 1994 Novell, Inc.  All rights reserved.
  3. **
  4. **    Permission is granted to the recipient of this work ("you") to use,
  5. **    reproduce and distribute Novell's original publication of the work free
  6. **    of charge provided that you reproduce the work in its entirety and
  7. **    include all Novell copyright notices as they originally appear.
  8. **
  9. **    Novell grants you permission to modify and distribute copies of this
  10. **    work including any portion of this work (a "modified work") provided
  11. **    that you include prominent notification of such modification along with
  12. **    the date of modification on a modified work; distribute or publish a
  13. **    modified work to third parties under the same conditions and granting
  14. **    the same rights as are extended to you by Novell under this under
  15. **    permission notice; and provided that you include a copy of Novell's
  16. **    original publication of the work along with any copy of a modified
  17. **    work.
  18. **
  19. **    NOVELL MAKES NO WARRANTY, REPRESENTATION OR PROMISE THAT THIS WORK OR A
  20. **    MODIFIED WORK WILL SATISFY YOUR REQUIREMENTS OR THAT THIS WORK OR A
  21. **    MODIFIED WORK IS WITHOUT DEFECT OR ERROR.  NOVELL DISCLAIMS AND
  22. **    EXCLUDES ANY AND ALL IMPLIED WARRANTIES OF MERCHANTABILITY, TITLE OR
  23. **    FITNESS FOR A PARTICULAR PURPOSE.
  24. **
  25. **    IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL NOVELL OR ANY OTHER
  26. **    PARTY BE LIABLE FOR DAMAGES INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
  27. **    CONSEQUENTIAL, INDIRECT OR PUNATIVE DAMAGES ARISING OUT OF THE USE OF
  28. **    OR INABLITITY TO USE THE WORK OR A MODIFIED WORK.
  29. **
  30. **    DSAUDIT.CPP - October 1994
  31. **
  32. **    Volume and container auditing.
  33. **
  34. **    The volume and container auditing APIs have been combined into a
  35. **    single API set. The type of auditing being performed depends on
  36. **    whether LoginAsVolumeAuditor or LoginAsContainerAuditor is executed.
  37. **    The member functions of DSAudit determine the type of auditing being
  38. **    performed and execute the appropriate auditing API.
  39. **
  40. **    Author: John Buckle, Asia Pacific Support Centre, Novell Australia
  41. **    ==================================================================
  42. **    9 Jan 1995           First release              John Buckle
  43. */
  44.  
  45. # include "dsdefs.h"
  46. # include "dsaudit.h"
  47.  
  48. DSAudit::~DSAudit()
  49. {
  50.     if (attached() && ObjectID) LogoutAsAuditor() ;
  51. }
  52.  
  53. NWDSCCODE DSAudit::AddAuditProperty(DWORD objectID)
  54. {
  55.     return Status = (AuditContainer)
  56.         ? NWDSChangeObjectAuditProperty(ConnHandle,ObjectID,AuditKey,ObjectID,1)
  57.         : NWAddAuditProperty           (ConnHandle,ObjectID,AuditKey,objectID) ;
  58. }
  59.  
  60. NWDSCCODE DSAudit::ChangeAuditorPassword(BYTE * password, BYTE level)
  61. {
  62.     return Status = (AuditContainer)
  63.         ? NWDSChangeAuditorPassword(ConnHandle,ObjectID,AuditKey,password,level)
  64.         : NWChangeAuditorPassword  (ConnHandle,ObjectID,AuditKey,password,level) ;
  65. }
  66.  
  67. NWDSCCODE DSAudit::ChangeAuditProperty(DWORD objectID, BYTE flag)
  68. {
  69.     return Status = (AuditContainer)
  70.         ? NWDSChangeObjectAuditProperty(ConnHandle,ObjectID,AuditKey,objectID,flag)
  71.         : flag
  72.           ? NWAddAuditProperty   (ConnHandle,ObjectID,AuditKey,objectID)
  73.           : NWRemoveAuditProperty(ConnHandle,ObjectID,AuditKey,objectID) ;
  74. }
  75.  
  76. NWDSCCODE DSAudit::CheckAuditAccess()
  77. {
  78.     return (AuditContainer)
  79.         ? NWDSCheckAuditAccess(ConnHandle,ObjectID)
  80.         : NWCheckAuditAccess  (ConnHandle,ObjectID) ;
  81. }
  82.  
  83. NWDSCCODE DSAudit::CheckAuditLevelTwoAccess()
  84. {
  85.     return Status = (AuditContainer)
  86.         ? NWDSCheckAuditLevelTwoAccess(ConnHandle,ObjectID,AuditKey)
  87.         : NWCheckAuditLevelTwoAccess  (ConnHandle,ObjectID,AuditKey) ;
  88. }
  89.  
  90. NWDSCCODE DSAudit::CloseOldAuditingFile()
  91. {
  92.     return Status = (AuditContainer)
  93.         ? NWDSCloseOldAuditingFile(ConnHandle,ObjectID,AuditKey)
  94.         : NWCloseOldAuditingFile  (ConnHandle,ObjectID,AuditKey) ;
  95. }
  96.  
  97. NWDSCCODE DSAudit::DeleteOldAuditingFile()
  98. {
  99.     return Status = (AuditContainer)
  100.         ? NWDSDeleteOldAuditingFile(ConnHandle,ObjectID,AuditKey)
  101.         : NWDeleteOldAuditingFile  (ConnHandle,ObjectID,AuditKey) ;
  102. }
  103.  
  104. NWDSCCODE DSAudit::DisableAuditingOnObject()
  105. {
  106.     return Status = (AuditContainer)
  107.         ? NWDSDisableAuditingOnContainer(ConnHandle,ObjectID,AuditKey)
  108.         : NWDisableAuditingOnVolume     (ConnHandle,ObjectID,AuditKey) ;
  109. }
  110.  
  111. NWDSCCODE DSAudit::EnableAuditingOnObject()
  112. {
  113.     return Status = (AuditContainer)
  114.         ? NWDSEnableAuditingOnContainer(ConnHandle,ObjectID,AuditKey)
  115.         : NWEnableAuditingOnVolume     (ConnHandle,ObjectID,AuditKey) ;
  116. }
  117.  
  118. NWDSCCODE DSAudit::GetAuditingFlags(NWFLAGS & flags)
  119. {
  120.     return Status = (AuditContainer)
  121.         ? NWDSGetAuditingFlags(ConnHandle,ObjectID,AuditKey,& flags)
  122.         : NWGetAuditingFlags  (ConnHandle,ObjectID,AuditKey,& flags) ;
  123. }
  124.  
  125. NWDSCCODE DSAudit::GetObjectAuditStats(void * buffer, WORD size)
  126. {
  127.     if (AuditContainer){
  128.         if (size == 0) size = sizeof(NWContainerAuditStatus) ;
  129.         return Status = NWDSGetContainerAuditStats(ConnHandle,ObjectID,
  130.                     (NWContainerAuditStatus *)buffer,size) ;
  131.         }
  132.     else {
  133.         if (size == 0) size = sizeof(NWVolumeAuditStatus) ;
  134.         return Status = NWGetVolumeAuditStats(ConnHandle,ObjectID,
  135.                     (NWVolumeAuditStatus*)buffer,size) ;
  136.         }
  137. }
  138.  
  139. NWDSCCODE DSAudit::InitAuditFileRead(int fileCode)
  140. {
  141.     FileCode = fileCode ;
  142.     EofFlag  = 0 ;
  143.     return Status = NWInitAuditFileRead(ConnHandle,ObjectID,fileCode,AuditContainer) ;
  144. }
  145.  
  146. NWDSCCODE DSAudit::InitAuditLevelTwoPassword(BYTE * password)
  147. {
  148.     return Status = NWInitAuditLevelTwoPassword(AuditKey,password) ;
  149. }
  150.  
  151. NWDSCCODE DSAudit::IsObjectBeingAudited(DWORD objectID)
  152. {
  153.     return Status = (AuditContainer)
  154.         ? NWDSIsObjectBeingAudited(ConnHandle,ObjectID,AuditKey,objectID)
  155.         : NWIsUserBeingAudited    (ConnHandle,ObjectID,AuditKey,objectID) ;
  156. }
  157.  
  158. NWDSCCODE DSAudit::LoginAsContainerAuditor(DWORD container, BYTE * password)
  159. {
  160.     if (! attached()) return 0x8801 ;
  161.  
  162.     if (ObjectID) LogoutAsAuditor() ;
  163.  
  164.     Status = NWDSLoginAsContainerAuditor(ConnHandle,container,AuditKey,password) ;
  165.  
  166.     if (Status == (NWDSCCODE)0x8997){
  167.         NWDSEnableAuditingOnContainer(ConnHandle,container,AuditKey) ;
  168.         Status = NWDSLoginAsContainerAuditor(ConnHandle,container,AuditKey,(BYTE*)password) ;
  169.         }
  170.     if (Status == 0){
  171.         ObjectID = container ;
  172.         AuditContainer = 1 ;
  173.         FileCode = 0xffff ;
  174.         }
  175.     return Status ;
  176. }
  177.  
  178. NWDSCCODE DSAudit::LoginAsVolumeAuditor(DWORD volume, BYTE * password)
  179. {
  180.     if (! attached()) return 0x8801 ;
  181.  
  182.     if (ObjectID) LogoutAsAuditor() ;
  183.  
  184.     Status = NWLoginAsVolumeAuditor(ConnHandle,volume,AuditKey,password) ;
  185.  
  186.     if (Status == (NWDSCCODE) 0x8997){
  187.         NWEnableAuditingOnVolume(ConnHandle,volume,AuditKey) ;
  188.         Status = NWLoginAsVolumeAuditor(ConnHandle,volume,AuditKey,password) ;
  189.         }
  190.     if (Status == 0){
  191.         ObjectID = volume ;
  192.         AuditContainer = 0 ;
  193.         FileCode = 0xffff ;
  194.         }
  195.     return Status ;
  196. }
  197.  
  198. NWDSCCODE DSAudit::LogoutAsAuditor()
  199. {
  200.     if (! attached()) return 0x8801 ;
  201.  
  202.     Status = (AuditContainer)
  203.         ? NWDSLogoutAsContainerAuditor(ConnHandle,ObjectID,AuditKey)
  204.         : NWLogoutAsVolumeAuditor     (ConnHandle,ObjectID,AuditKey) ;
  205.  
  206.     ObjectID = 0 ;
  207.  
  208.     return Status ;
  209. }
  210.  
  211. NWDSCCODE DSAudit::ReadAuditConfigHeader(void * buffer, WORD size)
  212. {
  213.     if (AuditContainer){
  214.         if (size == 0) size = sizeof(NWDSContainerConfigHdr) ;
  215.         return Status = NWDSReadAuditConfigHeader(ConnHandle,ObjectID,AuditKey,
  216.                     (NWDSContainerConfigHdr *)buffer,size) ;
  217.         }
  218.     else {
  219.         if (size == 0) size = sizeof(NWConfigHeader) ;
  220.         return Status = NWReadAuditConfigHeader  (ConnHandle,ObjectID,AuditKey,
  221.                     (NWConfigHeader *)buffer,size) ;
  222.         }
  223. }
  224.  
  225. NWDSCCODE DSAudit::ReadAuditingBitMap(NWAuditBitMap * buffer, WORD size)
  226. {
  227.     return Status = (AuditContainer)
  228.         ? 0x8811
  229.         : NWReadAuditingBitMap(ConnHandle,ObjectID,AuditKey,buffer,size) ;
  230. }
  231.  
  232. NWDSCCODE DSAudit::ReadAuditingFileRecord(void * buffer, WORD bufferSize, WORD & returnSize)
  233. {
  234.     if (EofFlag) return 0xffff ;
  235.  
  236.     Status = NWReadAuditingFileRecord(ObjectID,FileCode,buffer,& returnSize,bufferSize,& EofFlag) ;
  237.  
  238.     return (returnSize == 0) ? 0xffff : Status ;
  239. }
  240.  
  241. NWDSCCODE DSAudit::RemoveAuditProperty(DWORD objectID)
  242. {
  243.     return Status = (AuditContainer)
  244.         ? NWDSChangeObjectAuditProperty(ConnHandle,ObjectID,AuditKey,objectID,0)
  245.         : NWRemoveAuditProperty        (ConnHandle,ObjectID,AuditKey,objectID) ;
  246. }
  247.  
  248. NWDSCCODE DSAudit::ResetAuditHistoryFile()
  249. {
  250.     return Status = (AuditContainer)
  251.         ? 0x8811
  252.         : NWResetAuditHistoryFile(ConnHandle,ObjectID,AuditKey) ;
  253. }
  254.  
  255. NWDSCCODE DSAudit::ResetAuditingFile()
  256. {
  257.     return Status = (AuditContainer)
  258.         ? NWDSResetAuditingFile(ConnHandle,ObjectID,AuditKey)
  259.         : NWResetAuditingFile  (ConnHandle,ObjectID,AuditKey) ;
  260. }
  261.  
  262. NWDSCCODE DSAudit::WriteAuditConfigHeader(void * buffer)
  263. {
  264.     return Status = (AuditContainer)
  265.         ? NWDSWriteAuditConfigHeader(ConnHandle,ObjectID,AuditKey,
  266.                 (NWDSContainerConfigHdr *) buffer)
  267.         : NWWriteAuditConfigHeader  (ConnHandle,ObjectID,AuditKey,
  268.                 (NWConfigHeader *) buffer) ;
  269. }
  270.  
  271. NWDSCCODE DSAudit::WriteAuditingBitMap(NWEventBitMap * buffer)
  272. {
  273.     return Status = (AuditContainer)
  274.         ? 0x8811
  275.         : NWWriteAuditingBitMap(ConnHandle,ObjectID,AuditKey,buffer) ;
  276. }
  277.  
  278. # ifdef DSCPP_WINDOWS
  279. NWCCODE NWAPI NWDSIsObjectBeingAudited(NWCONN_HANDLE,LONG,BYTE NWFAR *,LONG)
  280. {
  281.     return 0x8811 ;
  282. }
  283.  
  284. NWCCODE NWAPI NWDSChangeObjectAuditProperty(NWCONN_HANDLE,LONG,BYTE NWFAR *,LONG,BYTE)
  285. {
  286.     return 0x8811 ;
  287. }
  288. # endif
  289.