This example shows how to create a dll file that will augment security in SalesLogix by wrapping around the existing security of Saleslogix.  This modifies sql statements as they come through the SalesLogix Provider.  So you have: If this table is in the join, add to the where clause.  In the example below, a user is only allowed to see contacts where they are set as the Contact’s Account Manager (Contact.AccountManagerID Field).

  1. Open up visual studio and create a new project.
    1. File -> New Project - Visual Basic -> Class library.
  2. Add a project reference to "SLXDBEngine 1.0 type library."
    1. Right Click the Project in the Solution Explorer -> Add Reference -> COM Tab -> "SLXDBEngine 1.0 type library."
  3. Add new item to project -> class named VBSecurityBroker.vb  (Case sensitive)
    1. Right Click the Project in the Solution Explorer -> Add -> New Item -> Class
    2. In Class, select all and paste code snippet over current text.  See below for Code Snippet.
  4. Add new Class called VBQuerySecurity.vb
    1. Right Click the Project in the Solution Explorer -> Add -> New Item -> Class
    2. In Class, select all and paste code snippet over current text.  See below for Code Snippet.
    3. Insert your custom code into the VBQuerySecurity.vb code where it says "'''YOUR SECURITY CODE GOES HERE"
  5. Delete class1
  6. Save all and build.
    1. Look for build succeeded in the lower left corner.
  7. View files in My DocumentsVS2005Projects...Debug.  We are worried about  ProjectName.dll and ProjectName.pdb.
    1. Copy both files into C:Program FilesSaleslogix
  8. Create a new .udl file to connect to your target SalesLogix database.
    1. Right click on the desktop and create a new text file.
    2. Rename the text file Saleslogix.udl.  (Or any name you would like to use.)
    3. Double click the file and fill in the information, making sure to use the SalesLogix OLE DB Provider.
    4. Copy udl file to C:Program FilesSaleslogix.
  9. Create or edit an existing .xml file.
    1. The class file .xml file code is below.
    2. Update the xml code to match your Project Name and a new SalesLogix ID.
    3. Copy xml file to C:Program FilesSaleslogix.
  10. Copy Interop.SLXDBEngineLib.dll, PluginWrapper.dll, and SLXPluginBuilder.exe to C:Program FilesSaleslogix.
    1. I found these files in the Sage SalesLogix class files.  They can also be found our built with the files in the SalesLogix DVD's SDK Examples folder.
  11. Open cmd prompt.
    1. cd C:Program FilesSaleslogix
    2. Run: "slxPluginBuilder.exe -n SLXDemo.dll"
      1. Creates wrapper for the dll, "DLLName.tlb"
    3. Run: "slxproviderplugin.exe -m SLXDemo.xml --udl new.udl"
      1. Inserts the value into db and sets it up to run when security is needed.
      2. Case sensitive
      3. This information is stored in the SLXOLEDBPLUGIN table.
        1. Can set SLXOLEDBPLUGIN.ENABLED to false if we want to turn off security plugin.
      4. The plugin(dll) security information is stored in the SLXOLEDBPLUGINDATA table.
  12. Log in and see if changes took effect.
  1. Imports System
  2. Imports System.Runtime.InteropServices
  3. Imports SLXDBEngineLib
  4. Imports System.Diagnostics
  5. _
  6.  
  7. Public Class VbSecurityBroker : Implements ISLXSecurityBroker
  8. Dim m_securityInit As SLXSECURITYINIT
  9.  
  10. Public Function GetSecurityObject(ByVal pSQLQuery As SLXDBEngineLib.SLXSQLQuery) _
  11. As ISLXQuerySecurity Implements ISLXSecurityBroker.GetSecurityObject
  12. If pSQLQuery.SQLType = SLXDBEngineLib.SLXSQLTYPE.SQLTYPE_SELECT Then
  13. Dim result As ISLXQuerySecurity = New VbQuerySecurity(m_securityInit, pSQLQuery)
  14. Return result
  15. Else
  16. Return Nothing
  17. End If
  18. End Function
  19.  
  20. Public Sub Initialize(ByRef pSecurityInit As SLXDBEngineLib.SLXSECURITYINIT) _
  21. Implements SLXDBEngineLib.ISLXSecurityBroker.Initialize
  22. m_securityInit = pSecurityInit
  23. End Sub
  24.  
  25. Public Sub Uninitialize() Implements SLXDBEngineLib.ISLXSecurityBroker.Uninitialize
  26.  
  27. End Sub
  28. End Class
  29.  
  30. vbQuerySecurity.vb Code Snippet:
  31. Imports System
  32. Imports System.Collections.Generic
  33. Imports System.Text
  34. Imports System.Runtime.InteropServices
  35. Imports SLXDBEngineLib
  36. Imports System.Diagnostics
  37.  
  38. Public Class VbQuerySecurity : Implements ISLXQuerySecurity
  39. Dim m_sqlQuery As SLXSQLQuery
  40. Dim m_securityInit As SLXSECURITYINIT
  41.  
  42. Public Sub New(ByVal securityInit As SLXSECURITYINIT, ByVal sqlQuery As SLXSQLQuery)
  43. m_securityInit = securityInit
  44. m_sqlQuery = sqlQuery
  45. End Sub
  46.  
  47. Public Function Secure() As QRYSECRESULT Implements ISLXQuerySecurity.Secure
  48. Dim res As QRYSECRESULT = QRYSECRESULT.QRYSEC_OK
  49. Dim cond As String
  50. Dim qSelect As SLXSelect = CType(m_sqlQuery, SLXSelect)
  51. If qSelect Is Nothing Then Return res
  52.  
  53. For Each stmt As SelectStmt In qSelect.SelectStmts
  54. For Each join As SQLJoin In stmt.SQLFrom.SQLJoins
  55. '''YOUR SECURITY CODE GOES HERE
  56. '''EXAMPLE:
  57. '''If join.Name = "CONTACT" Then
  58. '''cond = String.Format("{0}.ACCOUNTMANAGERID = '{1}'", join.Alias, '''m_securityInit.SLXUserID)
  59. '''stmt.SQLWhere.AddConditionFromString(cond, '''SLXSQL_CONDITIONAL.SQLCONDITION_AND)
  60. End If
  61. Next
  62. Next
  63. Return res
  64. End Function
  65. End Class
Posted in:

Looking for Infor help?

We do training, customization, integration, and much more. Contact us today.