Example for Loading Security

The following subroutine loads users and groups, security classes, role access definitions, and security class access definitions. The ValidateUsers load option is set to TRUE so that only valid Windows usernames in the load file will be loaded. Note how the example uses the Boolean returned by Load’s third argument to display a warning if the load file contains one or more invalid usernames.

Sub LoadSecACV(sFile As String, sLog As String)
Dim cSecurityLoadACV As HsvSecurityLoadACV
Dim cOptions As IHsvLoadExtractOptions
Dim cOpt As IHsvLoadExtractOption, vWarningSet
Set cSecurityLoadACV = New HsvSecurityLoadACV
'g_cSession is an HsvSession object reference
cSecurityLoadACV.SetSession g_cSession
'Initialize the IHsvLoadExtractOptions interface.
Set cOptions = cSecurityLoadACV.LoadOptions
'Set ValidateUsers to TRUE before loading.
Set cOpt = cOptions.Item _
   (HSV_SECURITYLOAD_OPT_AUTHENTICATE_USERS)
cOpt.CurrentValue = True
cSecurityLoadACV.Load sFile, sLog, vWarning
If vWarning = True Then
   MsgBox "The load file contained invalid user names." & _
   vbCrLf & "Check the log file for details."
End If
End Sub