Créer une bibliothèque UserNamePropertyClass
[syntax="ls"]
Public Class SuperUserNameProperty
Private m_session As NotesSession
Private m_db As NotesDatabase
Private m_dbNAB As NotesDatabase
Private m_view As NotesView
Private m_doc As NotesDocument
Property Get FullName As String
FullName=m_doc.FullName(0)
End Property
Property Get FirstName As String
FirstName=m_doc.FirstName(0)
End Property
Property Get LastName As String
LastName=m_doc.LastName(0)
End Property
Property Get ShortName As String
ShortName=m_doc.ShortName(0)
End Property
Property Get AllFullName As Variant
AllFullName=m_doc.FullName
End Property
Property Get AllFirstName As Variant
AllFirstName=m_doc.FirstName
End Property
Property Get AllLastName As Variant
AllLastName=m_doc.LastName
End Property
Property Get AllShortName As Variant
AllShortName=m_doc.ShortName
End Property
Property Get MailSystem As String
MailSystem=m_doc.MailSystem(0)
End Property
Property Get MailDomain As String
MailDomain=m_doc.MailDomain(0)
End Property
Property Get MailServer As String
MailServer=m_doc.MailServer(0)
End Property
Property Get MailFile As String
MailFile=m_doc.MailFile(0)
End Property
Property Get MailAddress As String
MailAddress=m_doc.MailAddress(0)
End Property
Property Get InternetAddress As String
InternetAddress=m_doc.InternetAddress(0)
End Property
Property Get AllInternetAddress As Variant
AllInternetAddress=m_doc.InternetAddress
End Property
Property Get JobTitle As String
JobTitle=m_doc.JobTitle(0)
End Property
Property Get CompanyName As String
CompanyName=m_doc.CompanyName(0)
End Property
Property Get Department As String
Department=m_doc.Department(0)
End Property
Property Get EmployeeID As String
EmployeeID=m_doc.EmployeeID(0)
End Property
Property Get Location As String
Location=m_doc.Location(0)
End Property
Property Get Manager As String
Manager=m_doc.Manager(0)
End Property
Property Get OfficePhoneNumber As String
OfficePhoneNumber=m_doc.OfficePhoneNumber(0)
End Property
Property Get OfficeFAXPhoneNumber As String
OfficeFAXPhoneNumber=m_doc.OfficeFAXPhoneNumber(0)
End Property
Property Get CellPhoneNumber As String
CellPhoneNumber=m_doc.CellPhoneNumber(0)
End Property
Public Function getUser(pUser As String)
Dim nn As NotesName
Dim ku As String
Set nn=New NotesName(pUser)
ku=nn.Abbreviated
Set m_doc=m_view.GetDocumentByKey(ku)
If m_doc Is Nothing Then
getUser=False
Else
getUser=True
End If
End Function
End Class
Public Class UserNameProperty As SuperUserNameProperty
Sub new(pServer As String,pLocal As Integer)
Dim sServer As String
If Trim$(pServer)<>"" Then
sServer=Trim$(pServer)
Else
If pLocal Then
sServer=""
Else
sServer=Trim$(pServer)
End If
End If
Set m_session=New NotesSession
Set m_db=m_session.CurrentDataBase
Set m_dbNAB=New NotesDatabase(sServer,"names.nsf")
Set m_view=m_dbNAB.Getview("($VIMPeople)")
End Sub
End Class
Function toString(s As Variant) As String
Dim i As Integer
If Isarray(s) Then
toString = s(Lbound(s))
For i = Lbound(s)+1 To Ubound(s)
toString = toString & "," & s(i)
Next
Else
toString = Cstr(s)
End If
End Function
[/syntax]
et voici un exemple d'utilisation
[syntax="ls"]
use "UserNameProperty"
Sub Initialize
Dim s As notessession
Dim db As notesdatabase
Dim unp As UserNameProperty
Set s=New notessession
Set db=s.currentdatabase
'// voir le constructeur pour plus d'explications
'// ============================
Set unp=New UserNameProperty("xxxServer",False)
'// on récupère les informations d'un utilisateur
'// =============================
If unp.GetUser(s.commonusername) Then
Msgbox unp.FirstName
Msgbox unp.LastName
Msgbox unp.FullName
Msgbox unp.ShortName
Msgbox unp.InternetAddress
Msgbox toString(unp.AllFullName)
Msgbox toString(unp.allInternetAddress)
Msgbox unp.MailSystem
Msgbox unp.MailServer
Msgbox unp.MailFile
Msgbox unp.MailAddress
Else
Msgbox "nok"
End If
End Sub
[/syntax]