Tags

CRM & Technology Management


Sales and Marketing Advisor


Sign Up For the Newsletter

Login

Welcome to the Technology Advisors Blog!!

Technology Advisors CRM and Technical Information
Mar 24
2010

How To Create A Sage SalesLogix Provider Plugin For Custom Security

Posted by: Justin Kuehlthau in MyBlog

Tagged in: Training

Justin Kuehlthau

    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"
    1. 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.
      1. The plugin(dll) security information is stored in the SLXOLEDBPLUGINDATA table.
  12. Log in and see if changes took effect.
  13.  

    vbSecurityBroker Code Snippet:
    Imports System

    Imports System.Runtime.InteropServices

    Imports SLXDBEngineLib

    Imports System.Diagnostics

     

    _

    Public Class VbSecurityBroker : Implements ISLXSecurityBroker

        Dim m_securityInit As SLXSECURITYINIT

     

        Public Function GetSecurityObject(ByVal pSQLQuery As SLXDBEngineLib.SLXSQLQuery) _

                As ISLXQuerySecurity Implements ISLXSecurityBroker.GetSecurityObject

            If pSQLQuery.SQLType = SLXDBEngineLib.SLXSQLTYPE.SQLTYPE_SELECT Then

                Dim result As ISLXQuerySecurity = New VbQuerySecurity(m_securityInit, pSQLQuery)

                Return result

            Else

                Return Nothing

            End If

        End Function

     

        Public Sub Initialize(ByRef pSecurityInit As SLXDBEngineLib.SLXSECURITYINIT) _

            Implements SLXDBEngineLib.ISLXSecurityBroker.Initialize

            m_securityInit = pSecurityInit

        End Sub

     

        Public Sub Uninitialize() Implements SLXDBEngineLib.ISLXSecurityBroker.Uninitialize

     

        End Sub

    End Class

     

    vbQuerySecurity.vb Code Snippet:

    Imports System

    Imports System.Collections.Generic

    Imports System.Text

    Imports System.Runtime.InteropServices

    Imports SLXDBEngineLib

    Imports System.Diagnostics

     

    Public Class VbQuerySecurity : Implements ISLXQuerySecurity

        Dim m_sqlQuery As SLXSQLQuery

        Dim m_securityInit As SLXSECURITYINIT

     

        Public Sub New(ByVal securityInit As SLXSECURITYINIT, ByVal sqlQuery As SLXSQLQuery)

            m_securityInit = securityInit

            m_sqlQuery = sqlQuery

        End Sub

     

        Public Function Secure() As QRYSECRESULT Implements ISLXQuerySecurity.Secure

            Dim res As QRYSECRESULT = QRYSECRESULT.QRYSEC_OK

            Dim cond As String

            Dim qSelect As SLXSelect = CType(m_sqlQuery, SLXSelect)

            If qSelect Is Nothing Then Return res

     

            For Each stmt As SelectStmt In qSelect.SelectStmts

                For Each join As SQLJoin In stmt.SQLFrom.SQLJoins

         '''YOUR SECURITY CODE GOES HERE

         '''EXAMPLE:

         '''If join.Name = "CONTACT" Then

              '''cond = String.Format("{0}.ACCOUNTMANAGERID = '{1}'", join.Alias, '''m_securityInit.SLXUserID)

              '''stmt.SQLWhere.AddConditionFromString(cond, '''SLXSQL_CONDITIONAL.SQLCONDITION_AND)

         End If

                Next

            Next

            Return res

        End Function

    End Class

     

    VBSLXSecurity.xml: (Put <> tags around the first line)

    ?xml version="1.0" encoding="utf-8" ?

     

     

     

Hits: 2492
Comments (1)Add Comment
0
...
written by Mark Toma, May 17, 2010
#9 - The XML code is given is incomplete (probably got HtmlEncoded). Maybe attach the sample or create a screenshot of it and post it.

Write comment
smaller | bigger

security code
Write the displayed characters


busy