Domino 9 und frühere Versionen > ND7: Entwicklung
Schreibberechtigung auf Profildokument
Annette:
Hallo an alle Experten,
ich sitze gerade vor folgendem Problem und komme (auch mit Hilfe der bestehenden Einträge nicht so recht weiter) :P:
Über Script erstelle ich im Hintergund ein Profildokument und setzte den aktuellen Usernamen (canonicalize) in ein Autorennamenfeld (isAuthors = True).
Wenn dieser User das Profildokument über Script (uidoc = ws.edit.profile) öffnet, kann er das Dokument nicht bearbeiten. Lt. Eigenschaften ist aber das Feld "AuthorNames" vorhanden und auch gefüllt.
Hat vielleicht jemand eine ähnliche Erfahrung gehabt und eine Ursache/Lösung gefunden?
Vielen Dank für jede Hilfe, selbst komme ich irgendwie nicht weiter :-:
DAU-in:
stell doch mal den Code rein
Annette:
HAllo, der gekürzte Code sieht so aus:
Function WriteProfil(doc As NotesDocument) As Variant
Dim session As New NotesSession
Dim db As NotesDatabase
Dim profiledoc As NotesDocument
Dim level As Integer
Dim username As NotesName ' Person des Profildok
Dim StrKonfigFeld As String ' Name des Konfig-Feldes in dem die Feld-Liste steht
Dim StrKonfigFeldOwn As String ' Name des Konfig-Feldes in dem die Profil-Feld-Liste steht (nur bei eigenen Anträgen)
Dim VarProfilFeldListe As Variant
Dim StrProfilFeld As String, StrDokumentFeld As String
Dim VarAutoren(1) As Variant
On Error Goto Error_M
' bestimmte Werte in das Profildokument zurückschreiben
Set db = session.CurrentDatabase
level = db.CurrentAccessLevel
If level > 2 Then
Set username = New NotesName (doc.Submitter(0))
Set profiledoc = db.GetProfileDocument( "profil", username.Canonical)
' ... den Code zum Besetzen der anderen Felder habe ich der Übersichtlichkeit wegenentfernt
VarAutoren(0) = "[DBMgr]"
VarAutoren(1) = username.Canonical
Set item = profiledoc.ReplaceItemValue("AuthorNames", VarAutoren)
item.IsAuthors = True
' SPEICHERN
Call profiledoc.Save (True, True)
End If
WriteProfil = True
Exit Function
Error_M:
Call ErrorMessage(Cstr(Lsi_info(2)), Cstr(Erl()), Error, Err(), Cstr(Lsi_info(3)), Cstr(Lsi_info(12)))
Exit Function
End Function
Annette:
Der Code zum BEarbeiten des PRofils ist folgender:
Function ProfilBearbeiten(doc As NotesDocument) As Variant
Dim session As New NotesSession
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim StrUserName As String
Dim username As NotesName
Dim uidoc As NotesUIDocument
Dim StrRollen As Variant
Dim DBMgrRole As Boolean
'=====================================================================================================
On Error Goto Error_M
DBMgrRole = False
Set db = session.currentdatabase
' 1.) ermitteln ob DBMgr oder normaler Anwender
'=====================================================================================================
StrRollen = db.QueryAccessRoles(session.UserName)
Forall x In StrRollen
If x = "[DBMgr]" Then
DBMgrRole = True
End If
End Forall
' a) Anwender ist DBMgr --> Auswahl des Profils
'==========================================================
If DBMgrRole = True Then
' kein Dokument übergeben (z. B. Aufruf aus Gliederung)
If doc Is Nothing Then
Set username = New NotesName(session.UserName)
' Antrag selbst erstellt
Elseif doc.Submitter(0) = "" Then
Set username = New NotesName(doc.Traveler(0))
' Antrag von Drittem
Else
Set username = New NotesName (doc.Submitter(0))
End If
StrUserName = ws.Prompt(PROMPT_OKCANCELEDIT, "Username", "Welches Profildokument soll bearbeitet werden?", Cstr(username.canonical), "")
If StrUserName = "" Then Exit Function
' b) Anwender ist kein DBMgr --> Profil des Anwenders öffnen
'==========================================================
Else
StrUserName = session.UserName
End If
' 2.) Profil zum Bearbeiten öffnen
'=====================================================================================================
Set uidoc = ws.EditProfile( "profil", StrUserName)
Exit Function
Error_M:
Call ErrorMessage(Cstr(Lsi_info(2)), Cstr(Erl()), Error, Err(), Cstr(Lsi_info(3)), Cstr(Lsi_info(12)))
Exit Function
End Function
koehlerbv:
Und was steht im Item Submitter? Warum musst Du dort überhaupt mit der Canonical-Property herumhantieren?
Bernhard
Navigation
[0] Themen-Index
[#] Nächste Seite
Zur normalen Ansicht wechseln