
ADDRESS BOOK
Change Mailserver For A 'Group' Of Users
Wil Conway 05.12.2000
Rating: --- (out of 5)




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.
|


');
// -->
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.
|
 |
|
|
 |
|
 |