VERSION 1.0 CLASS BEGIN MultiUse = -1 'True Persistable = 0 'NotPersistable DataBindingBehavior = 0 'vbNone DataSourceBehavior = 0 'vbNone MTSTransactionMode = 3 'UsesTransaction END Attribute VB_Name = "clsUsersDA" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = True Option Explicit '*** Constant declarations Private Const strMODULE_NAME As String = "clsUsersDA" '*** LDAP Configuration parameters Private Const dsNoSearchParameters = vbObjectError + 512 + 101 Private Const dssNoSearchParameters = "No Search Parameters." Private mstrLdapIdCode As String Public Property Let pstrLdapIdCode(ByVal strLdapIdCode As String) mstrLdapIdCode = strLdapIdCode End Property Public Property Get pstrLdapIdCode() As String pstrLdapIdCode = mstrLdapIdCode End Property '*** This functions returns a True/False indicating whether a user appinstance exists Public Function blnUserAppInstanceExists(ByVal strUserId As String, _ ByVal intAppInstanceId As Integer) As Boolean Dim objContext As ObjectContext Dim strSQL As String Dim objRS As ADODB.Recordset '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Treat strings strUserId = strFixStringForDatabaseInsertion(strUserId) '*** Create the SQL string strSQL = _ " SELECT User_Id" & _ " FROM user_app_instance" & _ " WHERE user_app_instance.user_id = '" & strUserId & "'" & _ " AND user_app_instance.app_instance_id = '" & intAppInstanceId & "'" '*** Create the recordset Set objRS = rsExecSQLAndReturnRecordset(strSQL, PublisherMeta) '*** Return whether user instance profile exists (true/false) If objRS.EOF <> True Then blnUserAppInstanceExists = True Else blnUserAppInstanceExists = False End If '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: If Not (objRS Is Nothing) Then Set objRS = Nothing Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".blnUserAppInstanceExists()]", Err.Description & " - SQL = " & strSQL End Function '*** This functions returns a True/False indicating whether a user exists Public Function blnUserExists(ByVal strUserId As String) As Boolean Dim objContext As ObjectContext Dim strSQL As String Dim objRS As ADODB.Recordset '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Treat strings strUserId = strFixStringForDatabaseInsertion(strUserId) '*** Create the SQL string strSQL = _ " SELECT users.user_id" & _ " FROM users" & _ " WHERE users.user_id = '" & strUserId & "'" & _ " AND deleted <> 1" '*** Create the recordset Set objRS = rsExecSQLAndReturnRecordset(strSQL, PublisherMeta) '*** Return whether user exists (true/false) If objRS.EOF <> True Then blnUserExists = True Else blnUserExists = False End If '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".blnUserExists()]", Err.Description & " - SQL = " & strSQL End Function '*** This functions returns a True/False indicating whether a user is marked for deletion Public Function blnUserMarkedForDelete(ByVal strUserId As String) As Boolean Dim objContext As ObjectContext Dim strSQL As String Dim objRS As ADODB.Recordset '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Treat strings strUserId = strFixStringForDatabaseInsertion(strUserId) '*** Create the SQL string strSQL = _ " SELECT users.user_id" & _ " FROM users" & _ " WHERE users.user_id = '" & strUserId & "'" & _ " AND deleted = 1" '*** Create the recordset Set objRS = rsExecSQLAndReturnRecordset(strSQL, PublisherMeta) '*** Return whether user was marked for deletion (true/false) If objRS.EOF <> True Then blnUserMarkedForDelete = True Else blnUserMarkedForDelete = False End If '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: If Not (objRS Is Nothing) Then Set objRS = Nothing Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".blnUserMarkedForDelete()]", Err.Description & " - SQL = " & strSQL End Function '*** This function determines if a user id exists in the LDAP Public Function blnUserExistsInLDAP(ByVal strUserId As String) As Boolean Dim objContext As ObjectContext Dim objUsersDA As ChvCITCUserMgr.clsUsersDA Dim rsUserAttributes As ADODB.Recordset '*** Enable error handling On Error GoTo ErrorHandler '*** Get the MTS Object Context Set objContext = GetObjectContext() '*** Create the data access object and execute the data access method If Not objContext Is Nothing Then Set objUsersDA = CreateObject("ChvCITCUserMgr.clsUsersDA") Else Set objUsersDA = New ChvCITCUserMgr.clsUsersDA End If '*** Search for the user - if found then a recordset is returned else and error is raised Set rsUserAttributes = objUsersDA.rsSearchLDAP(strUserId, "", "", "", "", "", "", "", _ "", "", "") blnUserExistsInLDAP = True '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: If Not (objUsersDA Is Nothing) Then Set objUsersDA = Nothing Return ErrorHandler: '*** If user not found error (from LDAP component call) then clear error and return falsue If Err.Number = -2147220477 Then Err.Clear blnUserExistsInLDAP = False GoSub CommonExit End If WriteDebugInfo "ldap_debug.txt", "Error # = " & Err.Number & "|" & _ "Error Description = " & Err.Description '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".blnUserIdExistsInLDAP()]", Err.Description End Function '*** This functions returns a True/False indicating whether a user MBP exists Public Function blnUserMBPExists(ByVal strAppInstanceAbbr As String, _ ByVal strUserId As String, _ ByVal strMBP As String) As Boolean Dim objContext As ObjectContext Dim strSQL As String Dim objRS As ADODB.Recordset '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Treat strings strUserId = strFixStringForDatabaseInsertion(strUserId) '*** Create the SQL string strSQL = _ " SELECT mbp_owner.process_name" & _ " FROM mbp_owner" & _ " WHERE mbp_owner.user_id = '" & strUserId & "'" & _ " AND mbp_owner.process_name = '" & strMBP & "'" '*** Create the recordset Set objRS = rsExecSQLAndReturnRecordset(strSQL, Publisher, strAppInstanceAbbr) '*** Return whether user instance profile exists (true/false) If objRS.EOF <> True Then blnUserMBPExists = True Else blnUserMBPExists = False End If '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: If Not (objRS Is Nothing) Then Set objRS = Nothing Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".blnUserMBPExists()]", Err.Description & " - SQL = " & strSQL End Function '*** This functions returns a True/False indicating whether a user role exists Public Function blnUserRoleExists(ByVal strAppInstanceAbbr As String, _ ByVal strUserId As String, _ ByVal strRole As String) As Boolean Dim objContext As ObjectContext Dim strSQL As String Dim objRS As ADODB.Recordset '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Treat strings strUserId = strFixStringForDatabaseInsertion(strUserId) '*** Create the SQL string strSQL = _ " SELECT user_role.role" & _ " FROM user_role" & _ " WHERE user_role.user_id = '" & strUserId & "'" & _ " AND user_role.role = '" & strRole & "'" '*** Create the recordset Set objRS = rsExecSQLAndReturnRecordset(strSQL, Publisher, strAppInstanceAbbr) '*** Return whether user has any roles (true/false) If objRS.EOF <> True Then blnUserRoleExists = True Else blnUserRoleExists = False End If '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: If Not (objRS Is Nothing) Then Set objRS = Nothing Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".blnUserRoleExists()]", Err.Description & " - SQL = " & strSQL End Function '*** This functions returns a True/False indicating whether a user has any roles Public Function blnUserHasAnyRoles(ByVal strAppInstanceAbbr As String, _ ByVal strUserId As String) As Boolean Dim objContext As ObjectContext Dim strSQL As String Dim objRS As ADODB.Recordset '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Treat strings strUserId = strFixStringForDatabaseInsertion(strUserId) '*** Create the SQL string strSQL = _ "SELECT user_role.role " & _ "FROM user_role " & _ "WHERE user_role.user_id = '" & strUserId & "'" '*** Create the recordset Set objRS = rsExecSQLAndReturnRecordset(strSQL, Publisher, strAppInstanceAbbr) '*** Return whether user has any roles (true/false) If objRS.EOF <> True Then blnUserHasAnyRoles = True Else blnUserHasAnyRoles = False End If '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: If Not (objRS Is Nothing) Then Set objRS = Nothing Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".blnUserHasAnyRoles()]", Err.Description & " - SQL = " & strSQL End Function '*************************************** 'Author: mimr 'Change This function changes a password in the LDAP '*************************************** Public Sub ChangePasswordInLDAP(ByVal strUserId As String, ByVal strNewPassword As String) Dim objContext As ObjectContext Dim objLDAPUM As ChvCITCLDAPUM.UserSecurityMaint Dim objError As ChvCITCLDAPUM.ErrorCodes '*** Enable error handling On Error GoTo ErrorHandler '*** Get the MTS Object Context Set objContext = GetObjectContext() '*** Change the password in the LDAP Set objLDAPUM = CreateObject("ChvCITCLDAPUM.UserSecurityMaint") objLDAPUM.ChangeUserPassword strLDAP_APP_NAME, pstrLdapIdCode, strUserId, strNewPassword Set objLDAPUM = Nothing '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: If Not (objLDAPUM Is Nothing) Then Set objLDAPUM = Nothing Return ErrorHandler: WriteDebugInfo "ldap_debug.txt", "Error # = " & Err.Number & "|" & _ "Error Description = " & Err.Description '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".ChangePasswordInLDAP()]", Err.Description End Sub '*** This procedure clears the current default user pub view Public Sub ClearDefaultUserPubView(ByVal strAppInstanceAbbr As String, _ ByVal strUserId As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " UPDATE user_pub_view SET default_view = 0" & _ " WHERE default_view = 1 and User_Id ='" & strUserId & "'" '*** Execute the query ExecSQL strSQL, Publisher, strAppInstanceAbbr '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".ClearDefaultUserPubView()]", Err.Description End Sub '*** This procedure clears the current default user pub view Public Sub UpdateUserPubView(ByVal strAppInstanceAbbr As String, _ ByVal lngViewId As Long, _ ByVal strViewName As String, _ ByVal intDefaultView As Integer) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " UPDATE user_pub_view SET view_name = '" & strViewName & "'," & _ "last_modified = SYSDATE, default_view = " & intDefaultView & _ " WHERE view_id = " & lngViewId '*** Execute the query ExecSQL strSQL, Publisher, strAppInstanceAbbr '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".UpdateUserPubView()]", Err.Description End Sub '*** This procedure updates the MBP name for any user pub views Public Sub UpdateUserPubViewsMBPName(ByVal strAppInstanceAbbr As String, _ ByVal strOldMBPName As String, _ ByVal strNewMBPName As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ "UPDATE user_pub_view SET mbp_name = '" & strNewMBPName & "' " & _ "WHERE mbp_name = '" & strOldMBPName & "'" '*** Execute the query ExecSQL strSQL, Publisher, strAppInstanceAbbr '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".UpdateUserPubViewsMBPName()]", Err.Description End Sub '*** This function renames user role assignments (to rename the role name associated to N users) Public Sub RenameUserRole(ByVal strAppInstanceAbbr As String, _ ByVal strOldRoleName As String, _ ByVal strNewRoleName As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Format SQL strSQL = _ "UPDATE user_role SET role = '" & strNewRoleName & "' " & _ "WHERE role = '" & strNewRoleName & "'" '*** Execute the query ExecSQL strSQL, Publisher, strAppInstanceAbbr '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".RenameUserRole()]", Err.Description End Sub '*** This function updates (inserts) the audit log with a new entry Public Sub UpdateAuditLog(ByVal strUserId As String, _ ByVal strTransType As String, _ ByVal strEditRecord As String, _ ByVal strTransDetail As String, _ ByVal strServerName As String, _ ByVal intInstanceId As Integer) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " INSERT INTO audit_log (id, edit_user_id, edit_datetime, trans_type, " & _ " edit_record, trans_detail, server_name, instance_id)" & _ " VALUES (" & intGetNextId(PublisherMeta, "id", "audit_log") & ",'" & strUserId & "'," & _ "SYSDATE,'" & strTransType & "','" & strEditRecord & "','" & _ Left(strTransDetail, 4000) & "','" & strServerName & "'," & intInstanceId & ")" '*** Execute the query ExecSQL strSQL, PublisherMeta '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".UpdateAuditLog()]", Err.Description End Sub '*** This function updates the specified user's attributes in the LDAP Public Sub UpdateUserInLDAP(ByVal strUserId As String, _ ByVal strFirstName As String, _ ByVal strLastName As String, _ ByVal strPassword As String, _ ByVal strPhoneNbr As String, _ ByVal strEmail As String, _ ByVal strCompanyName As String, _ ByVal strCountry As String) Dim objContext As ObjectContext Dim objLDAPUM As ChvCITCLDAPUM.UserSecurityMaint Dim objError As ChvCITCLDAPUM.ErrorCodes '*** Enable error handling On Error GoTo ErrorHandler '*** Get the MTS Object Context Set objContext = GetObjectContext() '*** Treat string for LDAP insertion strFirstName = strFixStringForDatabaseInsertion(strFirstName) strLastName = strFixStringForDatabaseInsertion(strLastName) strPhoneNbr = strFixStringForDatabaseInsertion(strPhoneNbr) strEmail = strFixStringForDatabaseInsertion(strEmail) strCompanyName = strFixStringForDatabaseInsertion(strCompanyName) strCountry = strFixStringForDatabaseInsertion(strCountry) strPassword = strFixStringForDatabaseInsertion(strPassword) '*** Change the user attributes in the LDAP Set objLDAPUM = CreateObject("ChvCITCLDAPUM.UserSecurityMaint") objLDAPUM.UpdateUser strLDAP_APP_NAME, pstrLdapIdCode, strUserId, _ "", "", strFirstName, "", strLastName, strPhoneNbr, strEmail, strLDAP_ROLE, _ strCompanyName, "", "", strCountry, "" '*** If a revised password was supplied then update the password also If strPassword <> "" Then objLDAPUM.ChangeUserPassword strLDAP_APP_NAME, pstrLdapIdCode, strUserId, strPassword End If Set objLDAPUM = Nothing '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: If Not (objLDAPUM Is Nothing) Then Set objLDAPUM = Nothing Return ErrorHandler: If Err.Number > dsLowerBound And Err.Number < dsUpperBound Then Set objError = New ChvCITCLDAPUM.ErrorCodes Err.Description = objError.GetErrorMessage(Err.Number) End If WriteDebugInfo "ldap_debug.txt", "Error # = " & Err.Number & "|" & _ "Error Description = " & Err.Description '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".UpdateUserInLDAP()]", Err.Description End Sub '*** This function creates new user in the USER table Public Sub CreateUser(ByVal strUserId As String, _ ByVal intExtranetOnly As Integer, _ ByVal strFirstName As String, _ ByVal strLastName As String, _ ByVal strPhoneNbr As String, _ ByVal strEmail As String, _ ByVal strCompanyName As String, _ ByVal strCountry As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ "INSERT INTO users (user_id, extranet_only, first_name, last_name, phone," & _ "email, country, company, login_count, last_modified, deleted, enabled) " & _ "VALUES ('" & strUserId & "'," & intExtranetOnly & ",'" & strFirstName & "','" & _ strLastName & "','" & strPhoneNbr & "','" & _ strEmail & "','" & strCountry & "','" & _ strCompanyName & "', 0, SYSDATE, 0, 1)" '*** Execute the query ExecSQL strSQL, PublisherMeta '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".CreateUser()]", Err.Description End Sub '*** This function creates a new user in the eQuest user group in the LDAP Public Sub CreateUserInDLAP(ByVal strUserId As String, _ ByVal strFirstName As String, _ ByVal strLastName As String, _ ByVal strPassword As String, _ ByVal strPhoneNbr As String, _ ByVal strEmail As String, _ ByVal strCompanyName As String, _ ByVal strCountry As String) Dim objContext As ObjectContext Dim objLDAPUM As ChvCITCLDAPUM.UserSecurityMaint Dim objError As ChvCITCLDAPUM.ErrorCodes '*** Enable error handling On Error GoTo ErrorHandler '*** Get the MTS Object Context Set objContext = GetObjectContext() '*** Treat each string for insertion into the LDAP strFirstName = strFixStringForDatabaseInsertion(strFirstName) strLastName = strFixStringForDatabaseInsertion(strLastName) strPhoneNbr = strFixStringForDatabaseInsertion(strPhoneNbr) strEmail = strFixStringForDatabaseInsertion(strEmail) strCompanyName = strFixStringForDatabaseInsertion(strCompanyName) strCountry = strFixStringForDatabaseInsertion(strCountry) '*** Create a new user and add the user to a group Set objLDAPUM = CreateObject("ChvCITCLDAPUM.UserSecurityMaint") objLDAPUM.CreateUser strLDAP_APP_NAME, pstrLdapIdCode, strUserId, _ strPassword, "", "", strFirstName, "", strLastName, strPhoneNbr, _ strEmail, strLDAP_ROLE, strCompanyName, "", "", strCountry, "", strLDAP_MASTER_GROUP Set objLDAPUM = Nothing '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: If Not (objLDAPUM Is Nothing) Then Set objLDAPUM = Nothing Return ErrorHandler: If Err.Number > dsLowerBound And Err.Number < dsUpperBound Then Set objError = New ChvCITCLDAPUM.ErrorCodes Err.Description = objError.GetErrorMessage(Err.Number) End If '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".CreateUserInDLAP()]", Err.Description End Sub '*** This function creates a user AppInstance entry Public Sub CreateUserAppInstance(ByVal strUserId As String, _ ByVal intAppInstanceId As Integer) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Treat strings strUserId = strFixStringForDatabaseInsertion(strUserId) '*** Create the SQL string strSQL = _ " INSERT INTO user_app_instance (user_id, app_instance_id)" & _ " VALUES ('" & strUserId & "'," & intAppInstanceId & ")" '*** Execute the query ExecSQL strSQL, PublisherMeta '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".CreateUserAppInstance()]", Err.Description & " - SQL = " & strSQL End Sub '*** This function creates a user MBP entry Public Sub CreateUserMBP(ByVal strAppInstanceAbbr As String, _ ByVal strUserId As String, _ ByVal strMBP As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " INSERT INTO mbp_owner (user_id, process_name)" & _ " VALUES ('" & strUserId & "','" & Trim(strMBP) & "')" '*** Execute the query ExecSQL strSQL, Publisher, strAppInstanceAbbr '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".CreateUserMBP()]", Err.Description End Sub '*** This function creates a user instance profile entry Public Sub CreateUserPubView(ByVal strAppInstanceAbbr As String, _ ByVal strUserId As String, _ ByVal strViewName As String, _ ByVal strMBPName As String, _ ByVal strMBPType As String, _ ByVal strTabName As String, _ ByVal intTabNumber As Integer, _ ByVal lngRowGroupId As Long, _ ByVal intPageNumber As Integer, _ ByVal intSortColumn As Integer, _ ByVal strSortColumnName As String, _ ByVal strSortDirection As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " INSERT INTO user_pub_view (user_id, view_id, view_name, last_modified," & _ "mbp_name, mbp_type, tab_name, tab_number, row_group_id, page_number," & _ "sort_column, sort_column_name, sort_direction, default_view)" & _ " VALUES ('" & strUserId & "'," & lngGetNextSequenceValue(Publisher, "PUB_SEQUENCE", strAppInstanceAbbr) & _ ",'" & strViewName & "'," & "SYSDATE,'" & strMBPName & "','" & strMBPType & "','" & _ strTabName & "'," & intTabNumber & "," & lngRowGroupId & "," & intPageNumber & _ "," & intSortColumn & ",'" & strSortColumnName & "','" & strSortDirection & "',0)" '*** Execute the query ExecSQL strSQL, Publisher, strAppInstanceAbbr '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".CreateUserPubView()]", Err.Description End Sub '*** This function creates a user role entry Public Sub CreateUserRole(ByVal strAppInstanceAbbr As String, _ ByVal strUserId As String, _ ByVal strRole As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " INSERT INTO user_role (user_id, role)" & _ " VALUES ('" & strUserId & "','" & strRole & "')" '*** Execute the query ExecSQL strSQL, Publisher, strAppInstanceAbbr '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".CreateUserRole()]", Err.Description End Sub '*** This function deletes the specified user from the LDAP Public Sub DeleteUserFromDLAP(ByVal strUserId As String) Dim objContext As ObjectContext Dim objLDAPUM As ChvCITCLDAPUM.UserSecurityMaint Dim objError As ChvCITCLDAPUM.ErrorCodes '*** Enable error handling On Error GoTo ErrorHandler '*** Get the MTS Object Context Set objContext = GetObjectContext() '*** Delete the user from the LDAP Set objLDAPUM = CreateObject("ChvCITCLDAPUM.UserSecurityMaint") objLDAPUM.DeleteUser strLDAP_APP_NAME, pstrLdapIdCode, strUserId Set objLDAPUM = Nothing '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: If Not (objLDAPUM Is Nothing) Then Set objLDAPUM = Nothing Return ErrorHandler: '*** If user not found then ok - resume next If Err.Number = -2147220477 Then Err.Clear Resume Next End If If Err.Number > dsLowerBound And Err.Number < dsUpperBound Then Set objError = New ChvCITCLDAPUM.ErrorCodes Err.Description = objError.GetErrorMessage(Err.Number) End If WriteDebugInfo "ldap_debug.txt", "Error # = " & Err.Number & "|" & _ "Error Description = " & Err.Description '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".DeleteUserFromDLAP()]", Err.Description End Sub '*** This function delete all the MBPs assigned to the specified user Public Sub DeleteUserMBPs(ByVal strAppInstanceAbbr As String, _ ByVal strUserId As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " DELETE FROM mbp_owner" & _ " WHERE mbp_owner.user_id = '" & strUserId & "'" '*** Execute the query ExecSQL strSQL, Publisher, strAppInstanceAbbr '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".DeleteUserMBPs()]", Err.Description End Sub '*** This function deletes the specified user pub view record for the specified user Public Sub DeleteUserPubView(ByVal strAppInstanceAbbr As String, _ ByVal lngViewId As Long) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " DELETE FROM user_pub_view" & _ " WHERE view_id = " & lngViewId '*** Execute the query ExecSQL strSQL, Publisher, strAppInstanceAbbr '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".DeleteUserPubView()]", Err.Description End Sub '*** This function deletes all the user pub view records for the specified user Public Sub DeleteUserPubViews(ByVal strAppInstanceAbbr As String, _ ByVal strUserId As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " DELETE FROM user_pub_view" & _ " WHERE user_id = '" & strUserId & "'" '*** Execute the query ExecSQL strSQL, Publisher, strAppInstanceAbbr '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".DeleteUserPubViews()]", Err.Description End Sub '*** This function deletes all the user pub view records by a user specified list '*** Adapted from DeleteUserPubViews() by jggr 11/5/01 Public Sub DeleteUserPubViewsByList(ByVal strAppInstanceAbbr As String, _ ByVal strViewIdList As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " DELETE FROM user_pub_view" & _ " WHERE view_id IN (" & strViewIdList & ")" '*** Execute the query ExecSQL strSQL, Publisher, strAppInstanceAbbr '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".DeleteUserPubViews()]", Err.Description End Sub '*** This function delete a specified role from a specified user Public Sub DeleteUserRole(ByVal strAppInstanceAbbr As String, _ ByVal strUserId As String, _ ByVal strRole As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ "DELETE FROM user_role " & _ "WHERE user_role.user_id = '" & strUserId & "' " & _ "AND user_role.role = '" & strRole & "'" '*** Execute the query ExecSQL strSQL, Publisher, strAppInstanceAbbr '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".DeleteUserRole()]", Err.Description End Sub Public Sub DeleteUserRolesForMBP(ByVal strAppInstanceAbbr As String, _ ByVal strRoleName As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ "DELETE FROM user_role " & _ "WHERE user_role.role = '" & strRoleName & "'" '*** Execute the query ExecSQL strSQL, Publisher, strAppInstanceAbbr '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".DeleteUserRolesForMBP()]", Err.Description End Sub '*** This function delete all the roles assigned to the specified user Public Sub DeleteUserRoles(ByVal strAppInstanceAbbr As String, _ ByVal strUserId As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " DELETE FROM user_role" & _ " WHERE user_role.user_id = '" & strUserId & "'" '*** Execute the query ExecSQL strSQL, Publisher, strAppInstanceAbbr '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".DeleteUserRoles()]", Err.Description End Sub '*** This functions delete the user entry for the specified user Public Sub DeleteUser(ByVal strUserId As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " DELETE FROM users" & _ " WHERE users.user_id = '" & strUserId & "'" '*** Execute the query ExecSQL strSQL, PublisherMeta '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".DeleteUser()]", Err.Description End Sub '*** This function marks the specified user entry for deletion Public Sub MarkUserForDelete(ByVal strUserId As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " UPDATE users SET last_modified = SYSDATE, deleted = 1" & _ " WHERE users.user_id = '" & strUserId & "'" '*** Execute the query ExecSQL strSQL, PublisherMeta '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".MarkUserForDelete()]", Err.Description End Sub '*** This function deletes the specified UserAppInstance entry Public Sub DeleteUserAppInstance(ByVal strUserId As String, _ ByVal intAppInstanceId As Integer) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " DELETE FROM user_app_instance" & _ " WHERE user_app_instance.user_id = '" & strUserId & "'" & _ " AND user_app_instance.app_instance_id = '" & intAppInstanceId & "'" '*** Execute the query ExecSQL strSQL, PublisherMeta '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".DeleteUserAppInstance()]", Err.Description End Sub '*** This function updates a user entry Public Sub UpdateUser(ByVal strUserId As String, _ ByVal strFirstName As String, _ ByVal strLastName As String, _ ByVal strPhoneNbr As String, _ ByVal strEmail As String, _ ByVal strCompanyName As String, _ ByVal strCountry As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " UPDATE users SET first_name = '" & strFirstName & "'," & _ "last_name = '" & strLastName & "', phone = '" & _ strPhoneNbr & "', email = '" & strEmail & "', company = '" & _ strCompanyName & "', country = '" & strCountry & "'," & _ "last_modified = SYSDATE, deleted = 0" & _ " WHERE users.user_id = '" & strUserId & "'" '*** Execute the query ExecSQL strSQL, PublisherMeta '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".UpdateUser()]", Err.Description End Sub '*** This function updates a user's login count and last login date Public Sub UpdateUserLogin(ByVal strUserId As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " UPDATE users SET last_logged_in = SYSDATE," & _ "login_count = (select login_count + 1 from users where users.user_id = '" & _ strUserId & "')" & _ " WHERE users.user_id = '" & strUserId & "'" '*** Execute the query ExecSQL strSQL, PublisherMeta '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".UpdateUser()]", Err.Description End Sub '*** This function updates the user table extranet_only flag Public Sub UpdateUserExtranetFlag(ByVal strUserId As String, ByVal intFlag As Integer) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " UPDATE users SET Extranet_only = " & intFlag & _ " WHERE users.user_id = '" & strUserId & "'" '*** Execute the query ExecSQL strSQL, PublisherMeta '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".UpdateUserExtranetFlag()]", Err.Description End Sub '*** This function updates a user's login count and last login date Public Sub UpdateUserView(ByVal strAppInstanceAbbr As String, _ ByVal strUserId As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Execute the query ExecSQL strUserId, Publisher, strAppInstanceAbbr '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".UpdateUserView()]", Err.Description End Sub '*** This function returns a recordset containing all user attributes Public Function rsGetAllUsers() As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " SELECT *" & _ " FROM users" & _ " WHERE deleted <> 1" & _ " ORDER BY last_name, first_name" '*** Create the recordset Set rsGetAllUsers = rsExecSQLAndReturnRecordset(strSQL, PublisherMeta) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetAllUsers()]", Err.Description End Function '*** This function returns a recordset containing all user attributes Public Function rsGetExpiredUsers(ByVal strExpireDate As String) As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ "SELECT user_id, first_name, last_name, email, last_logged_in " & _ "FROM users " & _ "WHERE last_modified < TO_DATE('" & strExpireDate & "','mm/dd/yyyy') " & _ "AND NVL(last_logged_in,last_modified) < TO_DATE('" & strExpireDate & "','mm/dd/yyyy') " & _ "AND DELETED <> 1 " & _ "ORDER BY user_id" '*** Create the recordset Set rsGetExpiredUsers = rsExecSQLAndReturnRecordset(strSQL, PublisherMeta) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetExpiredUsers()]", Err.Description End Function '*** This function returns a recordset containing the attributes for one or more users '*** from the LDAP based on the specified search criteria Public Function rsSearchLDAP(ByVal strUserId As Variant, _ ByVal strFirstName As Variant, _ ByVal strInitials As Variant, _ ByVal strLastName As Variant, _ ByVal strPhone As Variant, _ ByVal strEmail As Variant, _ ByVal strCompany As Variant, _ ByVal strEmployeeType As Variant, _ ByVal strDescription As Variant, _ ByVal strCountry As Variant, _ ByVal strUDF As Variant) As ADODB.Recordset Dim objContext As ObjectContext Dim objLDAPUM As ChvCITCLDAPUM.UserSecurityMaint Dim objError As ChvCITCLDAPUM.ErrorCodes On Error GoTo ErrorHandler '*** Get the MTS Object Context Set objContext = GetObjectContext() '*** Search for entries Set objLDAPUM = CreateObject("ChvCITCLDAPUM.UserSecurityMaint") Set rsSearchLDAP = objLDAPUM.SearchUserInfo(strLDAP_APP_NAME, _ pstrLdapIdCode, strUserId, strFirstName, strInitials, _ strLastName, strPhone, strEmail, strLDAP_ROLE, strCompany, strEmployeeType, _ strDescription, strCountry, strUDF) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: If Not (objLDAPUM Is Nothing) Then Set objLDAPUM = Nothing Return ErrorHandler: '*** If enumerated LDAP error then propigate error description If Err.Number > dsLowerBound And Err.Number < dsUpperBound Then Set objError = New ChvCITCLDAPUM.ErrorCodes Err.Description = objError.GetErrorMessage(Err.Number) '*** Else abort transaction Else If Not (objContext Is Nothing) Then objContext.SetAbort WriteDebugInfo "ldap_debug.txt", "Error # = " & Err.Number & "|" & _ "Error Description = " & Err.Description End If GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsSearchLDAP()]", Err.Description End Function '*** This function returns a recordset containing the specified AppInstance for the specified user Public Function rsGetUserAppInstance(ByVal strUserId As String, _ ByVal intAppInstanceId As Integer) As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " SELECT user_app_instance.app_instance_id" & _ " FROM user_app_instance" & _ " WHERE user_app_instance.user_id = '" & strUserId & "'" & _ " AND user_app_instance.app_instance_id = " & intAppInstanceId '*** Create the recordset Set rsGetUserAppInstance = rsExecSQLAndReturnRecordset(strSQL, PublisherMeta) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetUserAppInstance()]", Err.Description End Function '*** This function returns only the installed (enabled) AppInstances assigned to the specified user Public Function rsGetUserAppInstances(ByVal strUserId As String) As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ "SELECT ai.app_instance_id,ai.name, ai.abbr " & _ "FROM user_app_instance uai, app_instance ai " & _ "WHERE uai.user_id = '" & strUserId & "' " & _ "AND uai.app_instance_id = ai.id " & _ "AND ai.installed = 1 " & _ "ORDER BY ai.name" '*** Create the recordset Set rsGetUserAppInstances = rsExecSQLAndReturnRecordset(strSQL, PublisherMeta) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetUserAppInstances()]", Err.Description End Function '*** This function returns a recordset containing all the assigned AppInstances for the specified user Public Function rsGetAllUserAppInstances(ByVal strUserId As String) As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ "SELECT ai.id,ai.name " & _ "FROM user_app_instance uai, app_instance ai " & _ "WHERE uai.user_id = '" & strUserId & "' " & _ "AND uai.app_instance_id = ai.id " & _ "ORDER BY ai.name" '*** Create the recordset Set rsGetAllUserAppInstances = rsExecSQLAndReturnRecordset(strSQL, PublisherMeta) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetAllUserAppInstances()]", Err.Description End Function '*** This function returns a recordset containing the user attributes Public Function rsGetUserInfo(ByVal strUserId As String) As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " SELECT *" & _ " FROM users" & _ " WHERE deleted <> 1" & _ " AND user_id = '" & strUserId & "'" '*** Create the recordset Set rsGetUserInfo = rsExecSQLAndReturnRecordset(strSQL, PublisherMeta) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetUserInfo()]", Err.Description End Function '*** This function returns a recordset containing the MBPs owned by the specified user Public Function rsGetUserMBPs(ByVal strAppInstanceAbbr As String, _ ByVal strUserId As String, _ Optional ByVal strUserType As String) As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string Select Case strUserType Case "MBP_Owner_Only" strSQL = _ "SELECT Distinct A.PROCESS_NAME, A.ENABLED, A.PROCESS_TYPE, A.PROCESS_ORDER, B.User_Id " & _ "FROM PROCESS_TYPE A, MBP_OWNER B " & _ "WHERE A.PROCESS_NAME = B.PROCESS_NAME " & _ "AND B.user_id = '" & strUserId & "' " & _ "ORDER BY UPPER(PROCESS_NAME)" Case "MBP_Owner" strSQL = _ "SELECT Distinct A.PROCESS_NAME, A.ENABLED, A.PROCESS_TYPE, A.PROCESS_ORDER " & _ "FROM PROCESS_TYPE A, MBP_OWNER B " & _ "WHERE A.PROCESS_NAME = B.PROCESS_NAME " & _ "AND B.User_Id = '" & strUserId & "' " & _ "UNION SELECT A.PROCESS_NAME, A.ENABLED, A.PROCESS_TYPE, A.PROCESS_ORDER " & _ "FROM PROCESS_TYPE A, USER_TASKS B " & _ "WHERE A.PROCESS_NAME || '^MBPVIEW' = B.TASKNAME " & _ "AND B.User_Id = '" & strUserId & "' " Case "Site_Administrator" strSQL = _ "SELECT Distinct PROCESS_NAME, ENABLED, PROCESS_TYPE, PROCESS_ORDER " & _ "FROM PROCESS_TYPE " & _ "ORDER BY UPPER(PROCESS_NAME)" Case "User" strSQL = _ "SELECT Distinct A.PROCESS_NAME, A.ENABLED, A.PROCESS_TYPE, A.PROCESS_ORDER " & _ "FROM PROCESS_TYPE A, USER_TASKS B " & _ "WHERE A.PROCESS_NAME || '^MBPVIEW' = B.TASKNAME " & _ "AND B.User_Id = '" & strUserId & "' " & _ "ORDER BY UPPER(PROCESS_NAME)" End Select '*** Create the recordset Set rsGetUserMBPs = rsExecSQLAndReturnRecordset(strSQL, Publisher, strAppInstanceAbbr) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetUserMBPs)]", Err.Description End Function '*** This function returns a recordset containing the user pub views for a selected user Public Function rsGetUserPubViews(ByVal strAppInstanceAbbr As String, _ ByVal strUserId As String) As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string 'This query is won't run in ADO ' strSQL = _ ' " SELECT upv.view_id, upv.view_name, upv.mbp_name, upv.tab_name, upv.row_group_id, " & _ ' "upv.page_number, upv.sort_column, upv.default_view, upv.mbp_type, upv.tab_number, " & _ ' "upv.sort_direction, upv.sort_column_name, rg.name " & _ ' " FROM user_pub_view upv, rowgroup rg" & _ ' " WHERE upv.user_id = '" & strUserId & "'" & _ ' " AND upv.row_group_id = rg.rgroup_id(+)" strSQL = _ " SELECT view_id, view_name, mbp_name, tab_name, row_group_id, " & _ "page_number, sort_column, default_view, mbp_type, tab_number, " & _ "sort_direction, sort_column_name, last_modified" & _ " FROM user_pub_view upv" & _ " WHERE user_id = '" & strUserId & "'" '*** Create the recordset Set rsGetUserPubViews = rsExecSQLAndReturnRecordset(strSQL, Publisher, strAppInstanceAbbr) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetUserPubViews()]", Err.Description End Function '*** This function returns a recordset containing the user pub views for a selected user '*** Adapted from rsGetUserPubViews() jggr 11/06/01 Public Function rsGetUserPubViewsByList(ByVal strAppInstanceAbbr As String, _ ByVal strViewIdList As String) As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string 'strSQL = _ " SELECT user_pub_view.*, rg.name " & _ " FROM user_pub_view upv, rowgroup rg" & _ " WHERE view_id IN (" & strViewIdList & ")" & _ " AND upv.rgroup_id = rg.row_group_id(+)" '??? Who put this in here and why is the preceding code commented out ??? strSQL = _ " SELECT upv.*" & _ " FROM user_pub_view upv" & _ " WHERE view_id IN (" & strViewIdList & ")" '*** Create the recordset Set rsGetUserPubViewsByList = rsExecSQLAndReturnRecordset(strSQL, Publisher, strAppInstanceAbbr) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetUserPubViewsByList()]", Err.Description End Function Public Function rsGetUsersByList(ByVal strUsers As String) As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " SELECT *" & _ " FROM users" & _ " WHERE user_id IN (" & strUsers & ")" '*** Create the recordset Set rsGetUsersByList = rsExecSQLAndReturnRecordset(strSQL, PublisherMeta) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetUsersByList()]", Err.Description End Function '*** This function returns a recordset containing the user pub views for a selected user '*** Adapted from rsGetUserPubViews() jggr 11/05/01 Public Function rsGetUserPubView(ByVal strAppInstanceAbbr As String, _ ByVal lngViewId As String) As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " SELECT *" & _ " FROM user_pub_view" & _ " WHERE view_id = '" & lngViewId & "'" '*** Create the recordset Set rsGetUserPubView = rsExecSQLAndReturnRecordset(strSQL, Publisher, strAppInstanceAbbr) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetUserPubView()]", Err.Description End Function '*** This function returns a recordset containing the assigned roles for the specified user Public Function rsGetUserRoles(ByVal strAppInstanceAbbr As String, _ ByVal strUserId As String) As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " SELECT user_role.role" & _ " FROM user_role" & _ " WHERE user_role.user_id = '" & strUserId & "'" '*** Create the recordset Set rsGetUserRoles = rsExecSQLAndReturnRecordset(strSQL, Publisher, strAppInstanceAbbr) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetUserRoles)]", Err.Description End Function '*** This function returns a recordset containing the all users belonging to a specified role Public Function rsGetUsersBelongingToRole(ByVal strAppInstanceAbbr As String, _ ByVal strRole As String) As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " SELECT us.user_id, us.first_name, us.last_name, us.phone, us.email, us.company, us.country" & _ " FROM users us, user_role ur" & _ " WHERE ur.role = '" & strRole & "'" & _ " AND us.user_id = ur.user_id" & _ " AND us.deleted <> 1" & _ " ORDER BY us.last_name, us.first_name" '*** Create the recordset Set rsGetUsersBelongingToRole = rsExecSQLAndReturnRecordset(strSQL, Publisher, strAppInstanceAbbr) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetUsersBelongingToRole()]", Err.Description End Function '*** This function returns all extranet users Public Function rsGetAllExtranetUsers() As ADODB.Recordset Dim objContext As ObjectContext Dim objLDAPUM As ChvCITCLDAPUM.UserSecurityMaint Dim objError As ChvCITCLDAPUM.ErrorCodes On Error GoTo ErrorHandler '*** Get the MTS Object Context Set objContext = GetObjectContext() '*** Search for entries Set objLDAPUM = CreateObject("ChvCITCLDAPUM.UserSecurityMaint") Set rsGetAllExtranetUsers = objLDAPUM.SearchUserInfo(strLDAP_APP_NAME, _ pstrLdapIdCode, "*", "", "", "", "", "", "", "", "", "", "", "") '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: If Not (objLDAPUM Is Nothing) Then Set objLDAPUM = Nothing Return ErrorHandler: If Err.Number > dsLowerBound And Err.Number < dsUpperBound Then Set objError = New ChvCITCLDAPUM.ErrorCodes Err.Description = objError.GetErrorMessage(Err.Number) End If '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetAllExtranetUsers()]", Err.Description End Function '*** This function returns a recordset containing the default user pub view for a selected user Public Function rsGetDefaultUserPubView(ByVal strAppInstanceAbbr As String, _ ByVal strUserId As String) As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " SELECT *" & _ " FROM user_pub_view" & _ " WHERE user_id = '" & strUserId & "'" & _ " AND default_view = 1" '*** Create the recordset Set rsGetDefaultUserPubView = rsExecSQLAndReturnRecordset(strSQL, Publisher, strAppInstanceAbbr) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetDefaultUserPubView()]", Err.Description End Function '*** This function returns a recordset containing the users belonging to the current instance Public Function rsGetUsersForInstance(ByVal intAppInstanceId As Integer) As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ "SELECT us.user_id, us.first_name, us.last_name, us.phone, us.email, us.company, us.country " & _ "FROM users us, user_app_instance uai " & _ "WHERE us.user_id = uai.user_id " & _ " AND uai.app_instance_id = " & intAppInstanceId & " " & _ " AND us.deleted <> 1 " & _ "ORDER BY us.last_name, us.first_name" '*** Create the recordset Set rsGetUsersForInstance = rsExecSQLAndReturnRecordset(strSQL, PublisherMeta) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetUsersForInstance()]", Err.Description End Function Public Function rsGetActiveUsersByInstance(ByVal strFromDate As String, _ ByVal strToDate As String) As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ "SELECT t.name, t.total_users, a.active_users " & _ "FROM " & _ "(SELECT a1.name, count(*) total_users " & _ "FROM users u1, user_app_instance i1, app_instance a1 " & _ "WHERE u1.user_id = i1.user_id " & _ "AND i1.app_instance_id = a1.app_instance_id " & _ "GROUP BY a1.name) t, " & _ "(SELECT a2.name, count(*) active_users " & _ "FROM users u2, user_app_instance i2, app_instance a2 " & _ "WHERE u2.user_id = i2.user_id " & _ "AND i2.app_instance_id = a2.app_instance_id " & _ "AND u2.last_logged_in BETWEEN TO_DATE('" & strFromDate & "','mm/dd/yyyy') " & _ "AND TO_DATE('" & strToDate & "','mm/dd/yyyy') " & _ "GROUP BY a2.name) a " & _ "WHERE t.name = a.name(+) " & _ "ORDER BY t.name" '*** Create the recordset Set rsGetActiveUsersByInstance = rsExecSQLAndReturnRecordset(strSQL, PublisherMeta) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetActiveUsersByInstance()]", Err.Description End Function Private Sub Class_Initialize() '*** Assign production LDAP encryption key pstrLdapIdCode = strLDAP_ID_CODE_PROD '*** If in development mode then override production LDAP encryption key with test LDAP encryption key #If M_IF_IN_DEVELOPMENTMODE = 1 Then pstrLdapIdCode = strLDAP_ID_CODE_TEST #End If End Sub '*** This function returns a recordset containing the assigned AppInstances for the specified user Public Function rsGetUserAppInstancesAndGrids(ByVal strUserId As String) As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the temporary table, all_user_mbp strSQL = _ "BEGIN edaadpkg.load_all_mbp('" & strUserId & "'); END;" '*** ExecSQL strSQL, PublisherMeta '*** Create the SQL string strSQL = _ "SELECT user_id, instance_id, " & _ "instance_name, instance_abbr, process_name " & _ "FROM all_user_mbp " & _ "WHERE user_id = '" & strUserId & "' " & _ "ORDER BY upper(instance_name), upper(process_name)" '*** Create the recordset Set rsGetUserAppInstancesAndGrids = rsExecSQLAndReturnRecordset(strSQL, PublisherMeta) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetUserAppInstancesAndGrids()]", Err.Description End Function '*** This sub deletes the specified temporary Start Page Instances and Grids table (created by the rsGetUserAppInstancesAndGrids function) Public Sub DeleteInstancesAndGridsView(ByVal strUserId As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " DELETE FROM all_user_mbp" & _ " WHERE user_id = '" & strUserId & "' " '*** Execute the query ExecSQL strSQL, PublisherMeta '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: If Not (objContext Is Nothing) Then Set objContext = Nothing Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort '*** Clean up objects *** GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".DeleteInstancesAndGridsView()]", Err.Description & " - SQL String = " & strSQL End Sub Public Function rsGetMyViewsCount(strUserId, intDays) As ADODB.Recordset Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the temporary table, all_user_mbp strSQL = _ "BEGIN edaadpkg.load_myview_count('" & strUserId & "', " & intDays & "); END;" ExecSQL strSQL, PublisherMeta '*** Create the SQL string strSQL = _ "SELECT user_id, instance_id, " & _ "instance_name, view_id, view_name, mbp_name, flag_count " & _ "FROM myview_count " & _ "WHERE user_id = '" & strUserId & "' " & _ "ORDER BY upper(instance_name), upper(view_name)" '*** Create the recordset Set rsGetMyViewsCount = rsExecSQLAndReturnRecordset(strSQL, PublisherMeta) '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Function ObjectCleanup: Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".rsGetMyViewsCount()]", Err.Description End Function '*** This sub deletes the specified temporary Start Page Instances and Grids table (created by the rsGetUserAppInstancesAndGrids function) Public Sub DeleteMyViewsCount(ByVal strUserId As String) Dim objContext As ObjectContext Dim strSQL As String '*** Enable error handling On Error GoTo ErrorHandler '*** Acquire a reference to the transaction context Set objContext = GetObjectContext() '*** Create the SQL string strSQL = _ " DELETE FROM myview_count" & _ " WHERE user_id = '" & strUserId & "' " '*** Execute the query ExecSQL strSQL, PublisherMeta '*** Commit the transaction If Not (objContext Is Nothing) Then objContext.SetComplete CommonExit: GoSub ObjectCleanup Exit Sub ObjectCleanup: If Not (objContext Is Nothing) Then Set objContext = Nothing Return ErrorHandler: '*** Abort the transaction If Not (objContext Is Nothing) Then objContext.SetAbort '*** Clean up objects *** GoSub ObjectCleanup '*** Raise an error to the calling procedure Err.Raise Err.Number, Err.Source & "[" & strMODULE_NAME & ".DeleteMyViewsCount()]", Err.Description & " - SQL String = " & strSQL End Sub