Autor Thema: DB per Script in einem Agent öffnen  (Gelesen 3493 mal)

Offline Hoshee

  • Administrator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 697
  • Geschlecht: Männlich
  • Try To Be Mensch ...
    • Syslords Solutions IT-Dienstleistungen
DB per Script in einem Agent öffnen
« am: 03.04.02 - 14:54:15 »
Yoo,

ich möchte in einem Agent, der auf einem Server läuft, eine Datenbank eines anderen Servers öffnen (mit LotusScript).
Anscheinend ist das aber nicht so wirklich erlaubt   :P

Gibt es eine Möglichkeit, diese Restriktionen zu umgehen?

Rätselt ...

Hoshee
« Letzte Änderung: 01.01.70 - 01:00:00 von 1034200800 »
Detlef

-> Syslords Solutions
*************************************
Wer dem Chef in den Hintern kriecht, muß damit rechnen, daß er ihm eines Tages zum Hals heraushängt

Offline eknori

  • @Notes Preisträger
  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 11.728
  • Geschlecht: Männlich
Re: DB per Script in einem Agent öffnen
« Antwort #1 am: 03.04.02 - 15:02:50 »
Also isch wüßte nicht, warum das nicht gehen sollte.
Hier scheint mir ein Zugriffsproblem vorzuligen.
Hast du den Agenrten mit der ServerID unterzeichnet ?
Hat der Server überhaupt eine Zugriffsberechtigung auf den fremden Server ( und auf die DB ) ??a
« Letzte Änderung: 01.01.70 - 01:00:00 von 1034200800 »
Egal wie tief man die Messlatte für den menschlichen Verstand auch ansetzt: jeden Tag kommt jemand und marschiert erhobenen Hauptes drunter her!

Offline Hoshee

  • Administrator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 697
  • Geschlecht: Männlich
  • Try To Be Mensch ...
    • Syslords Solutions IT-Dienstleistungen
Re: DB per Script in einem Agent öffnen
« Antwort #2 am: 03.04.02 - 15:37:43 »
Yoo,

von den Rechten her sollte alles i.O. sein.
Im Protokoll des Agent bekomme ich folgende FM:

Code

03.04.2002 14:34:51: Error 4164: Cannot open databases on machines other than the server running your program (SRVXXXXXX/XXX!!names.nsf)


Gruss ...

Hoshee
« Letzte Änderung: 01.01.70 - 01:00:00 von 1034200800 »
Detlef

-> Syslords Solutions
*************************************
Wer dem Chef in den Hintern kriecht, muß damit rechnen, daß er ihm eines Tages zum Hals heraushängt

Offline eknori

  • @Notes Preisträger
  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 11.728
  • Geschlecht: Männlich
Re: DB per Script in einem Agent öffnen
« Antwort #3 am: 03.04.02 - 15:57:37 »
Hab das hier in der Knowledgebase gefunden.
Ich denke, daß du hier die Lösung findest.

Error: "Cannot Open Databases on Machines Other than the Server..."

Problem:

You have created a scheduled background agent that contains code similar to one of the samples below.  When you run the agent manually, it runs successfully.  When the agent is executed via the schedule, the following error message is written to the server's log file (LOG.NSF).

"Cannot open databases on machines other than the server running your program"

Code Sample #1:

Dim mySession as new NotesSession
Set myDB = mySession.GetDatabase("Server1","DBName.nsf")
'...

Code Sample #2:

Set DB = new NotesDatabase("Server1","DBName.nsf")
'...

Solution:

When a LotusScript agent generates the error when run as a background agent but runs fine when executed manually, use the following steps to troubleshoot the issue:

1.      This error occurs when the .NSF file you are accessing is located on a server other than the server where the background agent is running and when the server argument is not left empty.

     For example, the following two code samples in a scheduled agent cause the error:

Code Sample #1:

Dim mySession as new NotesSession
Set myDB = mySession.GetDatabase("Server1","DBName.nsf")
'...

Code Sample #2:

Set DB = new NotesDatabase("Server1","DBName.nsf")

     For security reasons, a background agent can access only databases that are local to the server where the agent is running.  To signify that the target database is located on the current (local) server in a scheduled agent, the server argument must be defined as a null string.  In the samples above, when "DBName.nsf" is located on the server where the agent is running, you must use the following syntax to identify the database:

For Sample #1:

Dim mySession as new NotesSession
Set myDB = mySession.GetDatabase("","DBName.nsf")
'...

For Sample #2:

Set DB = new NotesDatabase("","DBName.nsf")
'...

2.      The user who last saved or "stamped" the agent must be listed in the Run Unrestricted LotusScript Agents fields in the server document.  It may take a period of time for this update to take effect.  If it's necessary for the changes to take effect immediately then the Domino server would need to be shutdown and restarted.  For testing purposes, you can use an asterisk (*) entry in this fields to allow all users to run Unrestricted LotusScript calls - this should be done with some consideration as it will allow all users to run Unrestricted functions and methods.  Note:  When you have rights to run Unrestricted calls and methods this includes the rights to run the functions and methods which fall into the Restricted class.  For more information on the calls and methods that require Unrestricted access, see the document 137846 titled, 'LotusScript Agents that Require User's Name in "Run Unrestricted Agents"' ().

3.      The full hierarchical name of the server must be specified in LotusScript methods that reference databases via the NotesDatabase Class.  For example, when using the Open method:

           Call db.open("ServerA1/US/ACME","sales.nsf")

4.      The server name must be listed explicitly in any referenced database's  ACL and listed as Server, Manager.

5.      The following Notes methods are disallowed.

db Open, db OpenIfModified, new db, OpenMail

Supporting Information:

An enhancement request has been submitted to Lotus Quality Engineering to request that LotusScript have the functionality to access a database on another server.
« Letzte Änderung: 01.01.70 - 01:00:00 von 1034200800 »
Egal wie tief man die Messlatte für den menschlichen Verstand auch ansetzt: jeden Tag kommt jemand und marschiert erhobenen Hauptes drunter her!

Offline grosses.manitu

  • Junior Mitglied
  • **
  • Beiträge: 66
  • Geschlecht: Männlich
  • Ich liebe deutsche Element Begriffe...
Re: DB per Script in einem Agent öffnen
« Antwort #4 am: 03.04.02 - 22:31:01 »
Abend,

wie schon eknori geschrieben/kopiert hat, es ist nicht moeglich von einem Server ueber einen Agent der auf dem Server (nicht lokal) laeuft auf eine andere Datenbank zugreifen, die auf einem anderen Server liegt.
Das Problem kannst aber umgehen, wenn Du eine Replica (wie auch immer das in Deutsch heisst;-) ) der Datenbank auf den Server machst, wo der Agent laeuft.
« Letzte Änderung: 01.01.70 - 01:00:00 von 1034200800 »
------
Jeder muss mal gehen, die Frage ist einfach: Wann, Wohin, Warum... und mit Wem?

Offline Hoshee

  • Administrator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 697
  • Geschlecht: Männlich
  • Try To Be Mensch ...
    • Syslords Solutions IT-Dienstleistungen
Re: DB per Script in einem Agent öffnen
« Antwort #5 am: 04.04.02 - 13:59:16 »
Yoo,

das Problem ist nur, das ich überprüfen will, ob der andere Server erreichbar ist (in dem ich eine DB öffne).
D.h. das mir eine Replic nicht hilft (zumal die Server sowieso geclustert sind)   :-/

Hat denn jemand eine andere Idee, wie ich die Verfügbarkeit testen/prüfen kann?

Rätselt immer noch ...

Hoshee
« Letzte Änderung: 01.01.70 - 01:00:00 von 1034200800 »
Detlef

-> Syslords Solutions
*************************************
Wer dem Chef in den Hintern kriecht, muß damit rechnen, daß er ihm eines Tages zum Hals heraushängt

Offline christoph_berger

  • Frischling
  • *
  • Beiträge: 44
  • Geschlecht: Männlich
Re: DB per Script in einem Agent öffnen
« Antwort #6 am: 04.04.02 - 15:57:34 »
Moin Hoshee

Ein Mann genannt Ulrich Krause (--> EKnori?) postete einmal ein Stück Code mit dem man Server Commands ausführen kann. Vielleicht hilft dir das ja was ( e.g. sh task )

Gruss
Christoph

Link: http://searchdomino.techtarget.com/tip/1,289483,sid4_gci774870,00.html


Content:
Shortcut for executing server commands

Steve Holman
09 Oct 2001, Rating 4.53 (out of 5)

This tip is derived from a piece of code that was placed on the Notes.net Notes Gold Forum by Ulrich Krause. I modified it to make it easier for administrators to use and added functionality.

This is an example of how to send server task commands to a Domino Server using LotusScript and the WIN32 API. This allows for Administrators to use a form with a button, a view action, a form action, etc. to send commands to the server and in some cases see the results. Any "SHOW" command will show results, most others will come back with "Command Executed!" Follow the instructions below to set it up.

1. Create a blank form in a database. Name it anything you want.
2. Add a button to the form. The text for the button should be Console Command or something like that.
3. In the "Declarations" section of the button, copy and paste the code below.

Declare Function NSFRemoteConsole Lib "NNotes.dll" Alias "NSFRemoteConsole" (Byval Server As String, Byval cmd As String,
ret As Long) As Long
Declare Function OSLockObject Lib "NNotes.dll" Alias "OSLockObject"
(Byval Handle) As String
Declare Sub OSUnlockObject Lib "NNotes.dll" Alias "OSUnlockObject"
(Byval Handle)
Declare Sub OSMemFree Lib "NNotes.dll" Alias "OSMemFree" (Byval
Handle)
Class remoteConsole
     Private IsError As Variant
     Private rc As Integer
     Private hBuffer As Long
     Private Server As String
     Private Command As String
     Private Result As String
     
     Sub New(inpServer As String)
           Dim server As New NotesSession
           If inpServer = "" Then
                 Me.IsError = True
           Else
                 Me.server=inpServer
                 Me.IsError = False
           End If
     End Sub
     
     Function Execute(inpCommand As String, myserver As String) As String
           If Me.Server = "" Then
                 Me.Server = myserver
           End If
           If inpCommand = "" Then
                 Me.execute="You must specify a command"
                 Me.iserror = True
                 Exit Function
           Else
                 Me.command = inpCommand
           End If
           
           Me.rc = NSFRemoteConsole(Me.server, Me.command, hBuffer)
           If Me.rc <> 0 Then
                 Me.iserror = True
                 Me.result="Error returned " & _
                 " from console [" & Cstr(rc) & "]"
           Else
                 Me.result = OSLockObject(hBuffer)
                 Call OSUnlockObject(hBuffer)
                 Call OSMemFree(hBuffer)
                 Me.Iserror = False
           End If
           If Me.result = "" Then
                 Me.result = "Command executed!"
           End If
           Me.execute = Me.result
     End Function
End Class
4. In the "Click" section of the button, copy and paste the code below.

Sub Click(Source As Button)
     Dim exec As String
     Dim remConsole As New RemoteConsole("")
     'Dim ws As New NotesUIWorkspace
     'Dim uidoc As NotesUIDocument
     Dim myserver As String
     'Dim mydatabase As String
     
     'Set uidoc = ws.CurrentDocument
     myserver = Inputbox$("Type a server name", "Remote Console
Task", "<server>")
     'mydatabase = uidoc.FieldgetText( "RI_MailFileNm" )
     Exec = Inputbox$("Enter a remote console task", "Remote
Console Task", "Sh Ta")
     If exec = "" Then
           Exit Sub
     Else
           Msgbox remConsole.Execute(exec, myserver), 0, "Results"
     End If
End Sub
5. Save the form.
6. Open the database via the client and then choose Create --> Your Form(whatever you named your form).
7. Click the button and watch it work.

You can get creative from there. Just one of its uses from my site is that we use it in a portal we create a long while back in a Notes Database. It's a database on the Notes client that can do anything our administrators need to do at our site.

Thanks,

Steve



Code


Declare Function NSFRemoteConsole Lib
"NNotes.dll" Alias "NSFRemoteConsole" (Byval Server As String, Byval cmd As String, ret As Long) As Long
Declare Function OSLockObject Lib "NNotes.dll" Alias "OSLockObject"
(Byval Handle) As String
Declare Sub OSUnlockObject Lib "NNotes.dll" Alias "OSUnlockObject"
(Byval Handle)
Declare Sub OSMemFree Lib "NNotes.dll" Alias "OSMemFree" (Byval
Handle)
Class remoteConsole
     Private IsError As Variant
     Private rc As Integer
     Private hBuffer As Long
     Private Server As String
     Private Command As String
     Private Result As String
     
     Sub New(inpServer As String)
           Dim server As New NotesSession
           If inpServer = "" Then
                 Me.IsError = True
           Else
                 Me.server=inpServer
                 Me.IsError = False
           End If
     End Sub
     
     Function Execute(inpCommand As String, myserver As String)
As String
           If Me.Server = "" Then
                 Me.Server = myserver
           End If
           If inpCommand = "" Then
                 Me.execute="You must specify a command"
                 Me.iserror = True
                 Exit Function
           Else
                 Me.command = inpCommand
           End If
           
           Me.rc = NSFRemoteConsole(Me.server, Me.command,
hBuffer)
           If Me.rc <> 0 Then
                 Me.iserror = True
                 Me.result="Error returned " & _
                 " from console [" & Cstr(rc) & "]"
           Else
                 Me.result = OSLockObject(hBuffer)
                 Call OSUnlockObject(hBuffer)
                 Call OSMemFree(hBuffer)
                 Me.Iserror = False
           End If
           If Me.result = "" Then
                 Me.result = "Command executed!"
           End If
           Me.execute = Me.result
     End Function
End Class


Sub Click(Source As Button)
     Dim exec As String
     Dim remConsole As New RemoteConsole("")
     'Dim ws As New NotesUIWorkspace
     'Dim uidoc As NotesUIDocument
     Dim myserver As String
     'Dim mydatabase As String
     
     'Set uidoc = ws.CurrentDocument
     myserver = Inputbox$("Type a server name", "Remote Console
Task", "<server>")
     'mydatabase = uidoc.FieldgetText( "RI_MailFileNm" )
     Exec = Inputbox$("Enter a remote console task", "Remote
Console Task", "Sh Ta")
     If exec = "" Then
           Exit Sub
     Else
           Msgbox remConsole.Execute(exec, myserver), 0, "Results"
     End If
End Sub
« Letzte Änderung: 01.01.70 - 01:00:00 von 1034200800 »

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz