/ Forums / Advansys Formativ / Creating Solutions with Formativ / Trusted Application and Multiple Logins

  • Creator
    Topic
  • #4048
    stuartcross
    Participant

      I have been provided with 2 example applets for trusted applications. The first one creates the Trusted application. This one seems to work without any problems. I can see the application in my Trusted Applications list in C1. The second applet is supposed to use this trusted application and then seacrh through all mailboxes for a certain string. I have adapted this applet for testing so that it will only connect to my account and search for message with test in the subject or message body. It seems to be able to to pick up the correct Application name and Key however it is unable to use the Multilogin to access my account. If I enter the password of my account as one of the parameters then it will work. This would indicate to me that the Trusted Application part is probably not working. Is there any way I can test the MultiLogin with the Trusted Application?

      The applet that I am using is below.

      ‘ This is the text we want to search for
      const SEARCHTEXT = “test”
      const CMDLINE_PARAMS = “”
      const IDS_CAPTION = “DHO331 – Developing GroupWise® solutions with Advansys® Formativâ„¢”



      ‘ Read the trusted applet name and key from the registry. Use multilogon to
      ‘ login to each account and perform a search for the text defined in the
      ‘ constant SEARCHTEXT (see above).



      Sub Main(Client, GWEvent)

      dim TheName
      dim TheKey
      dim iAccount
      dim iTest
      dim iBooks
      dim iSearchRes
      dim iSearch

      ‘ Read the registry to object the name and key of the trusted application
      if not GetTrustedAppDetails(TheName, TheKey) then
      MsgBox “Could not determine the application name and/or key. Run ‘z Trusted Applet – Install’ and try again”, 0, IDS_CAPTION
      else

      iSearch = “crosss”
      ‘ Apply the trusted application credentials
      call GroupWise.Session.SetTrustedApplicationCredentials(“”+TheName+””, “”+TheKey+””)

      ‘ Use the Multilogin method to access the account
      on error resume next
      set iAccount = GroupWise.Session.Multilogin(iSearch, CMDLINE_PARAMS, null, egwPromptNever, null)
      ‘ Check if we were able to log into this users account
      if iAccount is nothing then
      MsgBox “Login Failed – Check the Trusted Application credentials and the command line paramters: ” & iSearch, 0, IDS_CAPTION
      else
      MsgBox(“IAccount OK”)
      ‘ OK – we have FULL ACCESS to the users account. Perform a find
      ‘ in an attempt to locate any references to the text in the constant
      ‘ SEARCHTEXT. We use a filter to do this.
      iFilter = “(SUBJECT CONTAINS “”” & SEARCHTEXT & “””) OR (MESSAGE CONTAINS “”” & SEARCHTEXT & “””)”
      set iMessages = iAccount.AllMessages.find(iFilter)
      ‘ Update the discover results
      if iMessages.Count > 0 then
      iSearchRes = iSearchRes & iSearch & “: “& vbTab & vbTab &iMessages.Count &” References to ‘” & SEARCHTEXT & “‘ were detected! <


      ” & vbCrLf
      else
      iSearchRes = iSearchRes & iSearch & “: ” & vbTab & vbTab &”No references detected.” & vbCrLf
      end if
      ‘ Remember to clean up this message collection
      set iMessages = nothing
      end if
      ‘ Release the account object we obtained
      set iAccount = nothing

      ‘ SetTrustedApplicationCredentials with empty strings to remove the credentials
      ‘ from the current session. If we don’t do this, we will be able to multi-login
      ‘ to any account for the remainder of this GroupWise session. This may or may not
      ‘ be the desired effect…
      call GroupWise.Session.SetTrustedApplicationCredentials(“”,””)

      ‘ Display the results in a message box.
      MsgBox iSearchRes, 0, “Research Process Complete”

      end if

      end Sub



      ‘ Obtain the trusted application details from the registry



      function GetTrustedAppDetails(ByRef AppName, ByRef AppKey)

      dim iRegistry

      GetTrustedAppDetails = False
      AppName = “”
      AppKey = “”

      set iRegistry = Utilities.Registry
      iRegistry.RootKey = fHKEY_CURRENT_USER
      if iRegistry.OpenKey(“SoftwareAdvansys CorporationDH0331 Trusted Applet”, True) then
      if iRegistry.ValueExists(“Name”) then
      AppName = iRegistry.ReadString(“Name”)
      end if
      if iRegistry.ValueExists(“Key”) then
      AppKey = iRegistry.ReadString(“Key”)
      end if
      iRegistry.CloseKey
      end if
      set iRegistry = nothing

      GetTrustedAppDetails = ((Len(AppName) > 0) and (Len(AppKey) > 0))

      end function

      Thanks,

      Stuart

    • Author
      Replies
    • #6956
      Support 1a
      Participant

        Hello Stuart,

        I tried your code, and it worked for me once I created the trusted application object. However, the first time I tried it after creating the object it didn’t work – I observed the same behaviour you did. However, I tried it again and it work on subsequent attempts. Perhaps their is some latency involved in the installation of the trusted application object to the server? I would be interested to see if it works if you try it again. Please let me know.

        If it still fails, could you please post a coy of the configuration information from the machine you are running this on so I can get a picture of your environment.

        Regards,

        Advansys Support

        #6954
        stuartcross
        Participant

          I have tried running the applet again and have had the same results. The message I get is “Login Failed – Check the Trusted Application credentials and the command line paramters:crosss”. This is the error that is displayed when iAccount is set to nothing as a result it seems that the multilogin is not working with the Trusted Application.

          The config of the machine I am using:

          [This message was edited by Support 1 on April 14, 2004 at 04:20 PM.]

          #6948
          Support 1a
          Participant

            Hello Stuart,

            Could you please try the following to see if it helps:

            1. Download the Trusted Application Binaries from http://developer.novell.com/ndk/gwtapp.htm

            2. You will find a file called GWTApp.dll in this download. Copy this file over the top of the existing version you should find in your GroupWise application directory (probably “C:NovellGroupWise”)

            3. Restart GroupWise and try again.

            Novell updated this file, but didn’t change it’s version resource, meaning it may not have been updated when you last installed Formativ.

            Please let me know how you proceed.

            Regards,

            Advansys Support

            #6950
            stuartcross
            Participant

              I have downloaded and installed this file. Unfortunately I am coming up with the same result.

              Is there any way to test that the SetTrustedApplicationCredentials is working properly? I was wondering if there was anyway to make sure that the trusted application is working properly.

              Regards,

              Stuart

              #6953
              Support 1a
              Participant

                None that I am aware of. I’ll create a simple test application (standalone, no Formativ) and make that available to you. We have a public holiday here tomorrrow and on Monday, so I may not be able to get something to you until Tuesday.

                Regards,

                Advansys Support

                [This message was edited by Support 1 on April 12, 2004 at 07:33 PM.]

                #6957
                Support 1a
                Participant

                  A test application has been sent to your registered email address.

                  Advansys Support

                  #6947
                  stuartcross
                  Participant

                    I have received the tesst application that you sent and have given it a go. This all works properly so I know the Trusted App’s are working. Thanks for that.

                    I then thought I would try removing the trusted app and start again. I tried running the applet to remove the trusted app and this failed. This got me thinking. The credentials that I am providing as App name and Key must be wrong. I have since found out that a colleague had run the Trusted App creation on his PC before I did it on mine. As a result I beleive the credentials I was using were incorrect. I have since manually removed the app through C1 and have recreated and then used the app above and it all works.

                    Thanks for the assistance.

                    Stuart

                    #6946
                    stuartcross
                    Participant

                      I have made some progress today with this applet. I have added some other accounts for it to search and have also improved the searching mechanism. The ultimate aim, though, is to find the relvant emails (which I can now do) and then once these have been found to forward them on to a manager. Is it possible to use this trusted application to then attach these emails to and email and send it to the manager?

                      If you need I can provide the applet that I am using.

                      Thanks,

                      Stuart

                      #6949
                      Support 1a
                      Participant

                        Hello Stuart,

                        Yes, it should be possible to modify your applet to forward messages to a designated account from the trusted application applet. You could call the .Forward method of the found message, which creates a draft message with the appropriate message attached, address the draft appropriately and finally call the send method. You could also create a new draft message, attach the appropriate message, and finally call send. You might want to also delete the sent item to remove evidence this procedure has been carried out if appropriate.

                        Feel free to post any code you are having problems with.

                        Regards,

                        Advansys Support

                        #6944
                        stuartcross
                        Participant

                          I am still having a few problems with getting the applet to use the trusted application to send the emails using the account I have connected to. The code I am using is below. I am able to search through the various mailboxes and find the relevant emails. When I then create a new mail message and attach these emails, it works on my account but not on the others. I believe it works for me because I am running the applet from within my GW account. I need to know how to send an email from an account I am connected to and then attach messages to these.

                          const CMDLINE_PARAMS = “”
                          ‘This is the domain we want to look for
                          const DOMAIN = “hotmail.com”
                          ‘This is who we want to forward the emails to
                          const MANAGER = “manager@test.com”

                          dim Msg
                          dim StringList
                          dim UserList
                          dim MailFound
                          dim iAccount
                          dim ItemtypeCount
                          dim iCount
                          dim HRT

                          ”””””””””””””””””””””””””””””””””””””””’
                          ‘ Connects to the accounts specified in UserList and searches for emails
                          ”””””””””””””””””””””””””””””””””””””””’
                          Sub Main(Client, GWEvent)

                          HRT = Chr(13) & Chr(10)
                          Set UserList = Utilities.StringList
                          UserList.Add(“account1”)
                          UserList.Add(“crosss”)
                          UserList.Add(“account2”)
                          UserList.Add(“account3”)
                          MailFound = 0
                          ‘ Apply the trusted application credentials
                          call GroupWise.Session.SetTrustedApplicationCredentials(“TrustedApp”, “1234”)
                          itemtypeCount = 0
                          Do While ItemtypeCount <> UserList.Count
                          Set StringList = Utilities.StringList
                          iSearch = UserList.Strings(ItemtypeCount)
                          ‘ Use the Multilogin method to access the account
                          on error resume next
                          set iAccount = GroupWise.Session.Multilogin(iSearch, CMDLINE_PARAMS, null, egwPromptNever, null)
                          ‘ Check if we were able to log into this users account
                          if iAccount is nothing then
                          MsgBox “Login Failed – Check the Trusted Application credentials and the command line paramters: ” & iSearch, 0, IDS_CAPTION
                          else
                          iFilter = (“(MAIL) AND (NOT OPENED)”)
                          set iMessages = iAccount.AllMessages.find(iFilter)
                          iCount = iMessages.Count
                          if iCount > 0 then
                          ‘ set each message object
                          for x = 1 to iCount
                          set Msg = iMessages.Item(x)
                          Checkmail
                          next
                          end if
                          ‘ Remember to clean up this message collection
                          set iMessages = nothing
                          end if
                          ‘ Release the account object we obtained

                          ItemTypeCount = ItemTypeCount + 1
                          if MailFound > 0 then
                          SendMail
                          end if
                          MailFound = 0
                          set iAccount = nothing
                          Loop
                          ‘ SetTrustedApplicationCredentials with empty strings to remove the credentials
                          ‘ from the current session. If we don’t do this, we will be able to multi-login
                          ‘ to any account for the remainder of this GroupWise session. This may or may not
                          ‘ be the desired effect…
                          call GroupWise.Session.SetTrustedApplicationCredentials(“”,””)

                          end Sub

                          ”””””””””””””””””””””””””””””””””””””””’
                          ‘ Check the Domain email is from and compare the time it was delivered with the current time
                          ”””””””””””””””””””””””””””””””””””””””’
                          function CheckMail
                          dim sDate
                          dim sTime
                          dim sCurDate
                          dim sCurTime

                          if (Instr(1, LCase(Msg.Sender.EmailAddress), LCase(DOMAIN))) <> 0 then
                          sDate=Utilities.DatetoISO(Msg.DeliveredDate)
                          If (Instr(1, sDate, “T”,1) <> 0) then
                          sArray = Split(sDate, “T”, -1, 1)
                          sDate = sArray(0)
                          sTime = sArray(1)
                          End If
                          sCurDate=Utilities.DatetoISO(Date+Time)
                          If (Instr(1, sCurDate, “T”,1) <> 0) then
                          sArray = Split(sCurDate, “T”, -1, 1)
                          sCurDate = sArray(0)
                          sCurTime = sArray(1)
                          End If
                          if sCurdate > sDate then
                          StringList.Add(Msg.Sender.DisplayName&” !! “&Msg.Subject&” !! “&Msg.CreationDate&” !! “&Msg.MessageID)
                          else
                          if sCurDate = sDate then
                          ‘if sCurTime-sTime > 20000 then
                          if sCurTime-sTime > 1 then
                          StringList.Add(Msg.Sender.DisplayName&” !! “&Msg.Subject&” !! “&Msg.CreationDate&” !! “&Msg.MessageID)
                          End if
                          End if
                          End if
                          CheckMail = TRUE
                          MailFound = MailFound + 1
                          exit function
                          end if

                          end function

                          ‘——————————————————————————-
                          ‘ Forward Emails to Manager
                          ‘——————————————————————————-
                          function SendMail

                          dim MyArray

                          Groupwise.NewMail
                          Set NewMsg = GroupWise.ComposingItem
                          NewMsg.To_ = MANAGER
                          NewMsg.Subject = “Unopened Messages within 2 hour period”
                          NewMsg.BodyText = HRT&HRT&HRT&”Forwarded Messages from : “&(iAccount.Owner)&HRT&HRT&”The attached messages have not been opened within the 2 hour period”
                          for x = 0 to (StringList.Count -1)
                          MyArray = Split(StringList.Strings(x), ” !! “, -1, 1)
                          call GroupWise.ItemAttachmentAdd(“X00″,115,MyArray(3),”Test”)
                          set NewMsg = nothing
                          set Msg = nothing
                          next
                          GroupWise.ItemSend(0)
                          end function

                          #6955
                          stuartcross
                          Participant

                            A little more progress

                            I have rewritten the SendMail function and am now able to get it to send emails from the specific user. The problem I am now having is actually attaching the emails to this new mail. The new SendMail function is below. The problem lies within the for statement. I am unsure what the command/syntax is to attach the mails to this new email. I have tried both methods which are commented out without success.

                            Thanks,

                            Stuart

                            function SendMail

                            dim MyArray
                            dim objMail
                            dim objNewMail
                            dim objRecipient
                            dim objAttachments

                            ‘ Create a draft mail message with no user interface
                            Set objMail = iAccount.MailBox.Messages.Add(“GW.MESSAGE.MAIL”, fgwDraft)
                            Set objRecipient = objMail.Recipients.Add(MANAGER,,0)
                            With objMail
                            .Priority = fgwNormal
                            .Subject = “Unopened Messages within 2 hour period”
                            .BodyText.PlainText = HRT&HRT&HRT&”Forwarded Messages from : “&(iAccount.Owner)&HRT&HRT&”The attached messages have not been opened within the 2 hour period”
                            End With
                            for x = 0 to (StringList.Count -1)
                            MyArray = Split(StringList.Strings(x), ” !! “, -1, 1)
                            ‘call objMail.Attachment.Add(MyArray(3)) ‘
                            ‘call objMail.AttachmentAddEncapsulatedItem(MyArray(3))
                            next
                            Set objNewMail = objMail.Send
                            Set objRecipient = Nothing
                            Set objMail = Nothing

                            end function

                            #6951
                            Support 1a
                            Participant

                              You need to use the draft message attachments property. Try something like (untested code):

                              ' You need to grab the actual message object you want to attach.
                              ' MyArray(3) here should hold the message id of the message you want to attach
                              set objMsg = iAccount.GetMessage(MyArray(3))
                              
                              ' Call the Attachments.Add method to add the actual message object
                              objMail.Attachments.Add(objMsg)
                              

                              I hope this helps

                              Advansys Support

                              #6945
                              stuartcross
                              Participant

                                Excellent. That seems to work.

                                I have another question now though. If I were to create a shared folder in each of these peoples mailboxes, is there a way that I am able to move these emails into that folder? Also, is it possible to get a list of users from a GW distribution list? We were thinking that if we could create a distribution list with the users that we need to search then we could read who the members are and then search these mailboxes.

                                Thanks heaps for the help so far.

                                Stuart

                                #6952
                                Support 1a
                                Participant

                                  To move a message between folders, move it from the old folder’s Messages collection to the new folder’s Messages collection. I have not tried it, but I expect it should also work with a shared folder. You need to use the Object API Folder.Messages collections to do this. See the Messages.Move method in the Object API documentation for more information.

                                  You need to use the Administrative Object API to access distribution lists in Formativ. Click the link above for to access the documentation. Formativ creates an instance of the Admin API for you via the GroupWise.AdminObject language command. GroupWise.AdminObject returns an instance of the Admin API System object. From here you connect to the appropriate GroupWise Domain, then locate and use the Distribution List you are interested in. Note that you need to have the NetWare Client installed to use the Admin Object API.

                                  I hope this helps.

                                  Advansys Support

                                Viewing 14 replies - 1 through 14 (of 14 total)
                                • You must be logged in to reply to this topic.