Internet address update for all users

Hi Team,

Can you please help me on how to change the internet address from flastname@domain.com to firstname.lastname@domain.com in domino directory for all users through lotus script?

example : aare@ibm.com to ashok.are@ibm.com

I want to do it for all the users in domino directory at a time.

Thanks & Regards,

Ashok

Subject: Remember Alias…

If you’re changing the Primary internet address, make sure that you add the current internet address field to the shortname field so that it will be an alias.

Here’s some rough code from when I had to do this many years ago.

Disclaimer - You will need to make modifications to this code so don’t just run it as is!

Disclaimer 2 - There are better ways to do some of this - but this should give you an idea.

Dim currentLog As New NotesLog( “UpdEmailAddr” )
Dim session As New NotesSession
Dim db As NotesDatabase
Dim NABdb As NotesDatabase
Dim NABpeople As NotesView
Dim NABdoc As NotesDocument
Dim username As NotesName
Dim item As notesitem

Dim USER As String

Dim USRF As String
Dim USRL As String
Dim USRA As String

Dim ErrCtr As Integer
Dim ErrNo As Integer
Dim ErrTxt As String

Set db = session.CurrentDatabase

Call currentLog.OpenNotesLog( db.Server , “agentlog.nsf” )
On Error Goto processError

Call currentLog.LogAction(“==> UpdEmailAddr Agent Starting…” )

’ ************************************************************************************************************************

Set NABdb = New notesDatabase(db.Server,“Names.nsf”)

Set NABpeople = NABdb.getView(“People”)

Set NABdoc = NABpeople.GetFirstDocument
While Not NABdoc Is Nothing

processuser:

'Verify Entry from FULLNAME field…

Set username = session.CreateName( NABdoc.FullName(0) )

USER = username.Common

Call currentLog.LogAction( " >" & USER & " Found…" )

'Set user variables from doc…

USRF = NABdoc.FirstName(0)
USRL = NABdoc.LastName(0)
OLDUSRA = NABdoc.InternetAddress(0)

'Verify the Internet Address field…

If ( Lcase ( Right ( OLDUSRA , 11 ) ) = “<yourorg.com>” ) Or ( OLDUSRA = “” ) Then

If OLDUSRA = “” Then
Call currentLog.LogAction( " ! NULL Internet Address Field !! Changing…" )

If USRF = “” Then
tempaddress = Lcase( USRL & “@<yourorg.com>”)
Else
tempaddress = Lcase( USRF & “.” & USRL & “@<yourorg.com>”)
End If

Else

Call currentLog.LogAction( " <yourorg.com> address found. Changing…" )
tempaddress = OLDUSRA

End If

Set item = NABdoc.GetFirstItem( “ShortName” )

Forall s In item.Values
If s = tempaddress Then
Call currentLog.LogAction( " ->" & tempaddress & " already found in ShortName, Skipping!" )
Goto foundit
End If

End Forall

Call currentLog.LogAction( " adding " & tempaddress & " to ShortName Field…" )

Call item.AppendToTextList( Lcase( tempaddress ))

foundit:
Else
ErrNo = 40
ErrTxt = OLDUSRA & " doesn’t match ‘<yourorg.com>’ (or not NULL) - going to next record"
Gosub LogErr
noupdctr = noupdctr + 1
USRA = OLDUSRA
End If

'Save the document

NABdoc.InternetAddress = USRA

Call currentLog.LogAction( " writing: ‘" & USRA & "’ to NAMES.NSF" )

If NABdoc.MailSystem(0) = “6” Then
Call currentLog.LogAction( " ! Changing MailSystem from 6 to 1" )
NABdoc.MailSystem = “1”
End If
If NABdoc.MessageStorage(0) = “0” Or NABdoc.MessageStorage(0) = “2” Then
Call currentLog.LogAction( " ! Changing Message Storage from " & NABdoc.MessageStorage(0) & " to 1" )
NABdoc.MessageStorage = “1”
End If

success = NABdoc.ComputeWithForm( False, False )

If Not success Then
ErrNo = 51
ErrTxt = "NABdoc.computeWithForm FAILED "
Gosub LogErr
noupdctr = noupdctr + 1
Goto noupdate
End If

success = NABdoc.Save( True , True )

If Not success Then
ErrNo = 52
ErrTxt = "NABdoc.Save FAILED for " & USER
Gosub LogErr
noupdctr = noupdctr + 1
Goto noupdate
End If

Call currentLog.LogAction( " -" & USER & " Record Updated…" )

noupdate:

Set NABdoc = NABpeople.GetNextDocument( NABdoc )
Wend

Goto THEEND

’ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LogErr: 'Log the error…
’ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Call currentLog.LogError( ErrNo, " " & Cstr(ErrNo) & " - " & ErrTxt )

Print Cstr(ErrNo) & " - " & ErrTxt
Return

’ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
processError: '9991
’ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
errctr = errctr + 1
If errctr = 100 Then Goto theend

ErrNo = 9991
ErrTxt = "Error " & Err() & ": " & Error() & " at Line# " & Erl()
Gosub LogErr

ErrNo = 9992
ErrTxt = "Processing stopped for UpdEmailAddr - User: " & USER & “. Going to next record”
Gosub LogErr

Resume noupdate

’ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Sub Routines End - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
’ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Sub Routines End - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Goto Complete

’ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
THEEND: 'This is the end of this routine!
’ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Call currentLog.LogAction(" —> UpdEmailAddr completed… " )

Call currentLog.Close

’ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

End Sub