Partager via


IFsrmSetting Interface

 

Used to configure FSRM.

Namespace:   Microsoft.Storage
Assembly:  srmlib (in srmlib.dll)

Syntax

[GuidAttribute("F411D4FD-14BE-4260-8C40-03B7C95E608A")]
public interface IFsrmSetting
[GuidAttribute("F411D4FD-14BE-4260-8C40-03B7C95E608A")]
public interface class IFsrmSetting
[<GuidAttribute("F411D4FD-14BE-4260-8C40-03B7C95E608A")>]
type IFsrmSetting = interface end
<GuidAttribute("F411D4FD-14BE-4260-8C40-03B7C95E608A")>
Public Interface IFsrmSetting

Properties

Name Description
System_CAPS_pubproperty AdminEmail

Retrieves or sets the email address for the administrator.

System_CAPS_pubproperty DisableCommandLine

Retrieves or sets a value that determines whether FSRM prevents command line actions from running.

System_CAPS_pubproperty EnableScreeningAudit

Retrieves or sets a value that determines whether FSRM keeps audit records of the file screen violations.

System_CAPS_pubproperty MailFrom

Retrieves or sets the default email address from which email messages are sent.

System_CAPS_pubproperty SmtpServer

Retrieves or sets the SMTP server that FSRM uses to send email.

Methods

Name Description
System_CAPS_pubmethod EmailTest(String)

Send an email message to the specified email address.

System_CAPS_pubmethod GetActionRunLimitInterval(_FsrmActionType)

Gets the time that an action that uses the global run limit interval must wait before the action is run again.

System_CAPS_pubmethod SetActionRunLimitInterval(_FsrmActionType, Int32)

Sets the time that an action that uses the global run limit interval must wait before the action is run again.

Remarks

To get this interface, call the CoCreateInstanceEx function. Use CLSID_FsrmSetting as the class identifier and __uuidof(IFsrmSetting) as the interface identifier.

To create this object from a script, use the program identifier, "Fsrm.FsrmSetting".

Examples

The following example shows how to retrieve the properties of this interface.

#ifndef UNICODE
#define UNICODE
#endif


#include <windows.h>
#include <stdio.h>
#include <comutil.h>
#include <fsrm.h>       // FSRM base objects and collections
#include <fsrmtlb_i.c>  // contains CLSIDs


//
// Print the FSRM configuration settings.
//
void wmain(void)
{
  HRESULT hr = 0;
  IFsrmSetting* pSettings = NULL;
  BSTR bstr = NULL;
  VARIANT_BOOL boolVal = VARIANT_FALSE;
  long interval = 0;

  hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
  if (FAILED(hr))
  {
    wprintf(L"CoInitializeEx() failed, 0x%x.\n", hr);
    exit(1);
  }

  hr = CoCreateInstance(CLSID_FsrmSetting, 
                        NULL,
                        CLSCTX_LOCAL_SERVER,
                        __uuidof(IFsrmSetting),
                        reinterpret_cast<void**> (&pSettings));

  if (FAILED(hr))
  {
    wprintf(L"CoCreateInstance(FsrmSetting) failed, 0x%x.\n", hr);
    if (E_ACCESSDENIED == hr)
      wprintf(L"Access denied. You must run the client with an elevated token.\n");

    goto cleanup;
  }

  wprintf(L"Successfully created Setting object.\n");

  // Get the default email address for the administrator. If set, you 
  // can then use the [Admin Email] macro for any action or report 
  // email address.
  hr = pSettings->get_AdminEmail(&bstr);
  if (FAILED(hr))
  {
    wprintf(L"pSettings->get_AdminEmail failed, 0x%x.\n", hr);
    goto cleanup;
  }

  wprintf(L"AdminEmail: %s\n", bstr);
  SysFreeString(bstr);

  // Determines whether FSRM allows command actions to execute. The default
  // is execute command actions.
  hr = pSettings->get_DisableCommandLine(&boolVal);
  if (FAILED(hr))
  {
    wprintf(L"pSettings->get_DisableCommandLine failed, 0x%x.\n", hr);
    goto cleanup;
  }

  wprintf(L"DisableCommandLine: %s\n", (VARIANT_TRUE == boolVal) ? L"True" : L"False");

  // Determines whether FSRM keeps audit records for file screen IO violations.
  // The default is not to keep audit records.
  hr = pSettings->get_EnableScreeningAudit(&boolVal);
  if (FAILED(hr))
  {
    wprintf(L"pSettings->get_EnableScreeningAudit failed, 0x%x.\n", hr);
    goto cleanup;
  }

  wprintf(L"EnableScreeningAudit: %s\n", (VARIANT_TRUE == boolVal) ? L"True" : L"False");

  // The default address from which reports and email actions are sent.
  // If set, you do not have to set the IFsrmActionEmail::MailFrom property.
  // The default is FSRM@<localdomain>
  hr = pSettings->get_MailFrom(&bstr);
  if (FAILED(hr))
  {
    wprintf(L"pSettings->get_MailFrom failed, 0x%x.\n", hr);
    goto cleanup;
  }

  wprintf(L"MailFrom: %s\n", bstr);
  SysFreeString(bstr);

  // Get the SMTP server. If not set, email is not sent.
  hr = pSettings->get_SmtpServer(&bstr);
  if (FAILED(hr))
  {
    wprintf(L"pSettings->get_SmtpServer failed, 0x%x.\n", hr);
    goto cleanup;
  }

  wprintf(L"SmtpServer: %s\n", bstr);
  SysFreeString(bstr);

  // Each action can specify an interval to wait before executing the action again.
  // The default for each action is 60 minutes.
  wprintf(L"Default interval, in minutes, to wait between executing an action:\n");

  hr = pSettings->GetActionRunLimitInterval(FsrmActionType_EventLog, &interval);
  if (FAILED(hr))
  {
    wprintf(L"pSettings->GetActionRunLimitInterval(FsrmActionType_EventLog) failed, 0x%x.\n", hr);
    goto cleanup;
  }

  wprintf(L"\tEventLog interval: %ld\n", interval);

  hr = pSettings->GetActionRunLimitInterval(FsrmActionType_Email, &interval);
  if (FAILED(hr))
  {
    wprintf(L"pSettings->GetActionRunLimitInterval(FsrmActionType_Email) failed, 0x%x.\n", hr);
    goto cleanup;
  }

  wprintf(L"\tEmail interval: %ld\n", interval);

  hr = pSettings->GetActionRunLimitInterval(FsrmActionType_Command, &interval);
  if (FAILED(hr))
  {
    wprintf(L"pSettings->GetActionRunLimitInterval(FsrmActionType_Command) failed, 0x%x.\n", hr);
    goto cleanup;
  }

  wprintf(L"\tCommand interval: %ld\n", interval);

  hr = pSettings->GetActionRunLimitInterval(FsrmActionType_Report, &interval);
  if (FAILED(hr))
  {
    wprintf(L"pSettings->GetActionRunLimitInterval(FsrmActionType_Report) failed, 0x%x.\n", hr);
    goto cleanup;
  }

  wprintf(L"\tReport interval: %ld\n", interval);

  hr = pSettings->put_SmtpServer(_bstr_t(L"<FQDNOFSMTPSERVER>"));
  if (FAILED(hr))
  {
    wprintf(L"pSettings->put_SmtpServer failed, 0x%x.\n", hr);
    goto cleanup;
  }

cleanup:

  if (pSettings)
    pSettings->Release();

  CoUninitialize();
}

See Also

Microsoft.Storage Namespace

Return to top