Macro to update EmailAddress property


I would need to update the emailaddress property of several users via a macro and was wondering how to achieve this exactly. I’ve attempted this and that via cognosscripting editor but fear that I’m yet sufficiently not familiar with it. Nonetheless, I have the impression that I repeatedly run into an error when calling the “OpenWithBasicSignon” command. Since I nowhere referred to my csa file and therefore do not specify any info with regard to DS, namespace, I wonder how this info is provided.

Any help would be greatly appreciated!


Hi Jozef,

with cognos script you can change the email adres of a user. you need a list of like:

john doe
jane doe

read this input file line by line. First column is used to search the LDAP conent and the email adres is the value you want to replace.

The CSA file is a type of config file which contains the configuration for access manager administration. You do not need it for the macro. The function OpenWithBasicSignon can be used with some parameters like namespace, user, password etc. When you open cognos script editor and use the right mouse button on the function you get the help function and syntax of the selected function.

With this piece of code you can check the openwithBasicsignon function with errorhandler.

Sub Main ()

DIM ObjAuthApp as object
DIM ObjAuthDoc as object

   On Error Goto Errhdlr1

   'Open Namespace

   Set ObjAuthApp = CreateObject("Authenticator2.Application")
   Set ObjAuthDoc = ObjAuthApp.Documents.OpenWithBasicSignon ("default", "administrator","password","Root User Class")

   MsgBox "Namespace opened successfully"
   Goto Done

   Msgbox "Error - " & Err & ": " & Error$


'Free up Memory 
set ObjAuthApp = Nothing
set ObjAuthDoc = Nothing

End Sub

What kind of errorcode do you get? Send it and we can go from there :slight_smile:

Hi Martijn,

Firstly, let me thank you for your contribution!

When I compile/execute your script, I do not get any errors…

Hereunder, I’ve tried to execute some IBM sample code (“How to export all users from Access Manager to a text filev”; available at:, as showed hereunder (modified the OpenWithBasicSignon parameters so they are in line with your script)

When compiled and executed this script, I get the error:
“Error 91: Object value is set to Nothingoccured”

Thanks in advance for your help!

[code] ’ Output is formatted as a comma delimited list to screen or file.
’ File is specified in the main.


Declare Sub User_classes(UsrClass as object)
Declare Sub Display_Users(Usrlist as object)

Sub Main ()

DIM objauthapp as object
DIM objauthdoc as object
DIM objuserclass as object
DIM msgtext as string

On Error Goto Errhdlr1

Set objauthapp = CreateObject("Authenticator2.Application")
Set objauthdoc = objauthapp.Documents.OpenWithBasicSignon ("default", "Administrator", "", "Root User Class")

Set objuserclass = objAuthDoc.RootUserClass

Open "c:\test\Userclass2.csv" for append as #1
Call User_classes(objuserclass)
close #1


Set objuserclass = Nothing
Set objauthdoc = Nothing
Set objauthapp = Nothing

exit sub

Errhdlr1:msgtext="Error " & Err & ": " _
& Error$ & "occurred."
Msgbox msgtext

End Sub

' ++++++++++++++++++++++++++++++++++++++++++++++++

' Display_Users function: 01-05-00 By Stephen Brown
' All users are output to file or screen (Comma delimited)
' for the User class object passed as a parameter.

Sub Display_Users(Usrlist as object)

Dim x as Integer
Dim objuser as object
Dim userlist as String

For x = Usrlist.Users.count to 1 step -1

Set objuser = Usrlist.users.item(x)
userlist = userlist & & chr$(44)

next x

' MsgBox "Name: " & & chr$ (44) & chr$ (10) _
' & "Users: " _
' & userlist & chr$ (44) & chr$(10)

write #1, & chr$ (44) & userlist

userlist = ""
Set objuser = Nothing

End Sub

' User_classes function: 01-05-00 By Stephen Brown

' Navigates the Userclass heirarchy of Namespace

Sub User_classes(UsrClass as object)

Dim y as Integer
Dim objUsrclass as object
Dim Objmaster as object
Dim Userclasscount as Integer

Set objUsrclass = UsrClass
Set objmaster = Usrclass
Userclasscount = objUsrclass.userclasses.count
Call Display_Users(objUsrclass)

If objUsrclass.userclasses.count <> 0 then
For y = Userclasscount to 1 step -1

Set objUsrclass = objmaster.userclasses.Item(y)
Call User_classes(objUsrclass)

Next y
End If

Set objUsrclass = Nothing
Set objmaster = Nothing

End Sub[/code]

try this script

change the const values to values that apply to your environment

Const AdminUser = "Administrator"
Const AdminSignon = ""
Const NameSpace = "default"
Const FileName = “D:\macro\Accessmanager\ClassUsers.Txt”

Note: NameSpace name is Case sensitive !!

' *====================================================================================================================
' * ClassUserList.mac
' *
' * This macro gets the userclass list and, for each userclass, the users list.
' * All are written into a text file.
' *
' *====================================================================================================================

Option Explicit

Sub Get_Users_List(UserClass As Object)

    Dim I As Integer

    If UserClass.Users.Count > 0 Then
        For I = 1 To UserClass.Users.Count
            Print #1, UserClass.Name & ":" & UserClass.Users(I).Name & ":" & UserClass.Description & ":" & UserClass.Users(I).Description
            Print #1, UserClass.Name & ":" & UserClass.Description & ":"
    End If

    If UserClass.UserClasses.Count >= 0 Then
        For I = 1 To UserClass.UserClasses.Count
            Call Get_Users_List(UserClass.UserClasses(I))
    End If
End Sub

Sub Main()

    Dim objAuthApp As Object ' Access Manager Application Object
    Dim objAuthDoc As Object ' Access Manager Document Object
    Dim objDSConfig As Object
    Const AdminUser = "Administrator"
    Const AdminSignon = ""
    Const NameSpace = "default"
    Const FileName = "D:\macro\Accessmanager\ClassUsers.Txt"

    ' Calls Access Manager and opens namespace with admin signon
    Set objAuthApp = CreateObject("Authenticator2.Application")
    Set objAuthDoc = objAuthApp.Documents.OpenWithBasicSignon(NameSpace, AdminUser, AdminSignon, 0)
    ' Opens output file and writes title
    Open FileName For Output As #1
    Print #1, "User Class:User Name"
    ' Calls recursive procedure for getting users list
    Call Get_Users_List(objAuthDoc.RootUserClass)
    ' Closes output file
    Close #1
    ' Exits Access Manager
    Set objAuthDoc = Nothing
    Set objAuthApp = Nothing

End Sub

Hi Martijn,

Can you check whether the 1st script is actually correct to check whether my namespace can open correctly? After all it seems that regardless of the parameters that I enter, that the script would always produce the success message “namespace opened successfully”

The reason why I went back to this original test script is because the latest script, i.e. CLASSUSERLIST.mac also produced an error, more specifically:
Error code : -1003
"ERROR exception not handled by program"

and I figured this might have been related to the parameters specified for the OpenWithBasicSignon command.

The issue is that I’m not sure (and can’t retrieve) which parameters have been applied in my environment; when I open Access Manager and define the directory server, I can simply access my namespace without entering any details; does this mean that I’m using the default user “Administrator” and blank password or should I verify this in another way?

Thanks already!


Hi Martijn,

In order to troubleshoot the issue described, probably also interesting to know is that the ClassUsers.txt file had been properly created in the specified location but only contained the following line:

User Class:User Name


Hi Jozef,

the User Class:User Name proofs that the creation of the text file works and that the macro write to the file.

i have not access to a series 7 environment right now. :-[
but i have some questions though:

  1. which Cognos version do you use?
  2. are you using cognos script to edit and run the scripts?
  3. is cognos script editor installed on the same computer were the access manager component is installed?

in cognos script editor there is a step debugging feature F7 or F8 i believe. F9 is run if i remeber correctly. This feature will highlight the line which will be executed by the next push of the button. Can you tell me on which line the -1003 error occurs?

Hi Martijn,

Thanks for your quick reply!

First I’ll answer your questions:

1. which Cognos version do you use?

Cognos 7.4

2. are you using cognos script to edit and run the scripts?

I’m indeed using the CognosScript Editor, to create a .mac script & to compile it to a .mcx executable; this executable is used to run the compiled script (so not run from within the CognosScript Editor, which btw is done with F5 ;-))

3. is cognos script editor installed on the same computer were the access manager component is installed?

The CognosScript Editor is indeed installed on the same machine as Access Manager; the underlying directory server, however, is running elsewhere.

When using the debugging feature (F8) from the .mac script in the CognosScript Editor, I could not reproduce the 1003 error, what I did find was that following line:


generated following error/warning:

“R91 Object Value is set to Nothing”

Would this generate the 1003 error once compiled? Moreover, from this error/warning message, it seems that the RootUserClass property of the objAuthDoc does not fetch anything; does this mean that the provided parameters for my namespace have been provided incorrectly?


It been a while since i used cognos script editor… :smiley:

Make sure you are member of the Root userclass (administrator)? when you automaticly log into access manager you might using the little yellow login key in the systemtray.
right mouse click -> Log off

Now you have to log on again when opening Access Manager. Look at the namespace name and type your credentials.
browse to the namespace structure and see if you are amember of the root user class