This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal


Apr 21, 2015, 7:14 PM
11 Posts
topic has been resolvedResolved

Extracting and moving an attachment

  • Category: Domino Designer
  • Platform: Windows
  • Release: 9.0.1
  • Role: Developer
  • Tags:
  • Replies: 15

I'm having some issues with my code below. When I run it from my local PC it works just fine, when the agent runs from the server it returns an error.

My Domino server is running under a Service Account in our domain that has full access to the share that I'm mapping to.

The .bat file is calling the "net use" mapping, it returns code 33 indicating success.

I put the Sleep command in to ensure it would complete the mapping before moving to the next steps.

Up until the "FileCopy" everything works well.

I'm using a profile document to store the relative folder to copy the file to.

//*************************

    Dim session As New NotesSession
    'On Error Resume next
    Set db = session.CurrentDatabase
    Set profile = db.GetProfileDocument("Profile")
    Pathname = profile.datapath(0)
    TPath = "D:\FAXDump\"
    'Tpath = "H:\FAXDump\"
    Set view = db.GetView("UnProcessed")
    Set doc = view.GetFirstDocument
    creturn = Shell("d:\faxdump\mapunc.bat",6)
    Print creturn
    Sleep 5.0
    While Not (doc Is Nothing)
        Set rtitem = doc.GetFirstItem( "Body" )
        If (rtitem.Type = RICHTEXT ) Then
            '  Detach all attachments in the document
            ForAll o In rtItem.EmbeddedObjects
                Fname$=o.Name
                Print "Extracting " & fname & " to " & tpath
                Call o.ExtractFile(TPath$&Fname$)
                filename = tpath & fname
                newfile = "z:" & pathname & fname
                Print "Copying " & filename & " to " & newfile
                FileCopy filename, newfile
            End ForAll
        End If
        Set tdoc = doc
        Set doc = view.GetNextDocument(doc)
        Call tdoc.ReplaceItemValue("Processed","1")
        Call tdoc.Save(True,True)
    Wend

//*************************

 

Agent Output

04/21/2015 02:01:27 PM  AMgr: Start executing agent 'DetachAttachmentsToUNC' in 'mail\stest.nsf'
04/21/2015 02:01:27 PM  Agent Manager: Agent printing: 33
04/21/2015 02:01:32 PM  Agent Manager: Agent printing: Extracting baseball_schedule.xlsx to D:\FAXDump\
04/21/2015 02:01:32 PM  Agent Manager: Agent printing: Copying D:\FAXDump\baseball_schedule.xlsx to z:\MIS\Messaging&Collaboration\baseball_schedule.xlsx
04/21/2015 02:01:32 PM  Agent Manager: Agent 'DetachAttachmentsToUNC' error: File not found
04/21/2015 02:01:32 PM  AMgr: Agent 'DetachAttachmentsToUNC' in 'mail\stest.nsf' completed execution

 

Any clues? I'm about ready to tell the AD guys they're going to need to create a script to manually copy any files over to the folders.

Apr 21, 2015, 8:23 PM
202 Posts
What security level did you give the agent?
And does the agent signer have the rights to run unrestricted agents on the server?  This is the Notes/Domino agent signer not the OS account.
Apr 21, 2015, 8:51 PM
11 Posts
Yes

I have security set to allow restricted ops with full admin rights.

Apr 21, 2015, 8:55 PM
202 Posts
And the agent signer, what rights do they have in the server document?
Apr 21, 2015, 9:20 PM
11 Posts
Full rights

The agent is signed with my admin ID, so full rights to run unrestricted and all other options.

Apr 21, 2015, 9:26 PM
11 Posts
I'm not sure if it is removed or not

It "shouldn't" be, but that's my question I guess. I can't find anything on the server at the OS level that's showing me any failed logins, etc. when it tries to run the "net use".

I know the files exist, I can RDP into the machine and see the files being placed in the correct local disk\folder.

I suppose I'm going to have to play with my batch file to see if I can make it take longer to fully execute to see if it's disconnecting.

I'll try seeing if I can read any of the existing docs from that shared directory as well.

Apr 22, 2015, 1:02 AM
326 Posts
Suggestion

In the batch file add >>C:\DEFUGFILE.TXT    to all lines so you can look at that file and see where it might have had issues.

Apr 22, 2015, 1:57 AM
191 Posts
Sounds like the old null session issue
Because the Domino process uses the Local System account, null sessions will be used to access network resources. I don't know if this has changed in any more recent versions of Windows, but the symptoms you describe seem to imply it hasn't. See here for an overview with workarounds.

https://support.microsoft.com/en-us/kb/124184
Apr 22, 2015, 1:19 PM
11 Posts
Chad

I'm not sure I completely understand. My Domino server service is running under an AD account that we've elevated to local admin privilege on the server and it has admin rights to the network share as well. Wouldn't any OS level processes initiated by the Domino server be run under that account? As well, my .bat file is mapping using the AD credentials for the service account, when I manually run the .bat file it maps as expected.

Apr 22, 2015, 5:18 PM
191 Posts
I misunderstood your comments
I thought you indicated Domino was running under the system account. Nevertheless, the symptoms are what we'd see with a null session type of issue. Is it possible the share is being mapped by the Local System account and attempting to access via a null share?
Apr 22, 2015, 2:03 PM
11 Posts
Batch file debug

When I put in debug in my bat file and run it from the agent it indicates that it can't find the file, when I run the bat file from the OS it finds it

//**************

net use z: \\chq2k8fs251\groupfolder$ <password> /user:<adminaccount>
if not exist "z:\mis\scott.txt" goto error1
echo File map exists > d:\faxdump\log.txt
goto end
:error1
echo Unable to find file > d:\faxdump\log.txt
:end

//**************

so it appears that Domino is running the .bat file but either not running the "net use" OR it's automatically closing the share almost immediately

Apr 22, 2015, 2:57 PM
326 Posts
Suggestion

For one you really should use >> as this appends to the output file.  Put a del of the file at the beginning of the batch file

 

If you open command prompt under that user id on the server and run just that command what happens?

Apr 22, 2015, 3:14 PM
11 Posts
it works

When I login to the server using the Admin credentials and manually run the .bat file it works just fine. Maps the drive, is able to access the file.

Apr 22, 2015, 4:08 PM
326 Posts
try
Maybe the z drive is already mapped.  Try

Net use z: /delete /y 

 

 

Echo all lines to the debug file.  If you to see what drives are mapped put Net Use >>c:\debugfile.txt at the very beginning of the bat file

 

Apr 22, 2015, 5:13 PM
11 Posts
strange

Strange... I modified my agent to issue a "net use z: /delete" right before calling the .bat file to map it.. now everything works just fine.

 


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal