Home > Domino Tips > Administrator > Address Book > Change Mailserver For A 'Group' Of Users
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ADDRESS BOOK

Change Mailserver For A 'Group' Of Users


Wil Conway
05.12.2000
Rating: --- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


This code allows you to change the mailserver for all users listed in a group.
It could easily be modified to change any field in a person document.

Code

Sub Initialize
On Error Goto Error_Handler
'===============================================================================
========
' AGENT INTRODUCTION
'===============================================================================
========
Continue = Msgbox ("This agent will change the mailserver entries for all
users in a group" & Chr(13) _
& "that you specify with the server that you specify." & Chr(13) _
& "Do you still wish to continue?",68,"'Change Mailserver for a Group of
Users' Agent")

If Continue = 7 Then
Exit Sub
End If
'===============================================================================
========
' DECLARATIONS
'===============================================================================
========
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim Groupdoc As NotesDocument
Dim Persondoc As NotesDocument
Dim myServerName As String
Dim myGroupName As String
Dim mycounter As Integer
'===============================================================================
========
' USER INPUT 'GROUP'
'===============================================================================
========
Enter_Group:
myGroupName = Inputbox ("What is the name of the group that has the users you
would like to convert?" _
, "Input Required")
'===============================================================================
========
' INPUT VALIDATION 'GROUP'
'===============================================================================
========
If myGroupName = "" Then
Exit Sub
End If
Set db = Session.CurrentDatabase
Set view = db.getview("Groups") 'Get group view
Set Groupdoc = view.getdocumentbykey(myGroupName,True) ' Get group doc
If (Groupdoc Is Nothing) Then
Msgbox "This is not a valid group. Please try again!", 16 ,"PROBLEM:"
Goto Enter_Group
End If
'===============================================================================
========
' USER INPUT 'SERVER'
'===============================================================================
========
Enter_Server:
myServerName = Inputbox ("What is the name of the server that you would like
to set these users to?" _
& Chr(13) & "Note: the server name must be canonicle", "Input Required", _
"CN=YourCN/OU=YourOU/O=YourO")
'===============================================================================
========
' INPUT VALIDATION 'SERVER'
'===============================================================================
========
If myServerName = "" Then
Exit Sub
Else
If Not (myServerName Like "CN=*" And _
myServerName Like "*OU=*" And _
myServerName Like "*O=*") Then
Msgbox "You did not enter the Server Name in the correct format!", 16
,"PROBLEM:"
Goto Enter_Server
End If
End If
'===============================================================================
========
' USER INPUT CHECK
'===============================================================================
========
Continue = Msgbox ("You are about to change the mailserver entry to " &
Chr(13) _
& myServerName & Chr(13) _
& "for all users in the " & "'" & myGroupName & "'" & " group." & Chr(13) _
& "Do you still wish to continue?",36,"'Change Mailserver for a Group of
Users' Agent")

If Continue = 7 Then
Exit Sub
End If
'===============================================================================
========
' MAIN CODE
'===============================================================================
========
Set view = db.getview("($Users)") ' Get user view

Forall x In Groupdoc.members
Set Persondoc = view.getdocumentbykey(x,True) ' Get user doc
If Not(Persondoc Is Nothing) Then
Persondoc.mailserver = myServerName 'Set new MailServer value
Call Persondoc.save (True,True) 'Save doc
Print "Modifying Person Doc For: " & x <WHATL

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Address Book
Formula language button manages Deny Access list searches
Find a Lotus Notes user within NAB Deny Access groups
Synchronize LinkedIn contacts with Lotus Notes Domino
How to correct Lotus Notes public key mismatches in four easy steps
Creating a Lotus Notes Personal Address Book replica
Admin user unable to create NAB
@Transform formula for use in R6
Change NAB while maintaining integrity of documents
NAB: A key piece of the Domino administration puzzle
Build an extended directory catalog

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts