Solved

VIew Access & Agent Update

Posted on 2011-09-22
15
384 Views
Last Modified: 2013-12-18
Here is the problem.  I have a database with 50+ views which I am migrating to another DB Manager.  Most of these views have specific users accessing each.  So the new DB Manager only sees the views where all users have access. You would think Notes would give a Manager default access to all views but it does not.  This forces me to go into each view to assign.  

Is there some way (maybe an agent) that could globally add access to a specified user?

Thank you in advance?
0
Comment
Question by:fdemello
  • 6
  • 6
  • 3
15 Comments
 
LVL 10

Expert Comment

by:larsberntrop
ID: 36585382
Er: use Roles?

Create role.

Assign role to DBManager

Assign Role to Views.
0
 

Author Comment

by:fdemello
ID: 36585397
Thanks. I had used Roles with Controlled Sections and didn't even notice they appear in the View access.  This is a great tip and I will always use this going forward.

However this doesn't help me on existing DB's.  I would still have to go one-by-one to set the Role in the view.  Any ideas?
0
 
LVL 10

Expert Comment

by:larsberntrop
ID: 36585648
Use ytria viewez
0
 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 36587131
RE: "Is there some way (maybe an agent) that could globally add access to a specified user?"

Yes, just modify the Readers property of the view.
Dim view as NotesView
Set view = db.getView('SomeView')
view.Readers = arrayOfUserNamesGroupsOrRoles

Open in new window

0
 

Author Comment

by:fdemello
ID: 36597666
Hi Bill - can you provide a little more info on the above.  I'm assuming it is Lotus Script entered into an Agent?  I had some problems trying to do that - if that was correct.

I have attached what I attempted to do but was not sure where to add the code


Thanks a lot  New Agent Script
0
 
LVL 10

Expert Comment

by:larsberntrop
ID: 36597991
Initialize part
0
 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 36598533
Yes, the code goes in the Initialize event of a LotusScript agent.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 36598546
Let me know if you want help setting up the user name array.
0
 

Author Comment

by:fdemello
ID: 36652479
Hi Bill,
I think I will need help on the user name array as well

Thanks again
0
 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 36707532
Sure, where are the names coming from?
0
 

Author Comment

by:fdemello
ID: 36707678
Would want to lookup the Access Control list
0
 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 36709399
OMG!  If I'd known that, I would just have said to add roles - so much easier!  All you have to do is add a role for each view, then assign roles in ACL.  But, if you are bent on updating view access programatically, here's how to do it.

The setViewReaders sub reads all People from the current ACL into an array and sets the view's Readers property.
%REM
	Sub setViewReaders
	Description: Sets the readers of a view to the ACL members.
	Parameter: viewName - The name or alias of the view to update.	
%END REM
Sub setViewReaders(viewName As String)
	' read people from acl into an array.
	Dim session As New NotesSession
	Dim db As NotesDatabase
	Dim acl As NotesACL
	Dim entry As NotesACLEntry
	Dim users As Variant
	Set db = session.Currentdatabase
	Set acl = db.Acl
	Set entry = acl.GetFirstEntry
	Do Until entry Is Nothing
		If (entry.Isperson) Then
			users = arrayAdd(users, entry.Name)
		End If
		Set entry = acl.Getnextentry(entry)
	Loop
	' set view readers.
	Dim view As NotesView
	Set view = db.Getview(viewName)
	view.Readers = users	
End Sub

Open in new window

The arrayAdd function is one you should add to your shared library.  It allows you to easily populate an array dynamically, and is used by the setViewReaders sub.
%REM
	Function arrayAdd(a1, a2)
	Description: Appends two values and returns the result as an array.
	Parameter: a1 - An array, scalar value, or object.
	Parameter: a2 - An array, scalar value, or object.
	Return: An array.
%END REM
Public Function arrayAdd(a1 As Variant, a2 As Variant) As Variant
	Dim array1 As Variant, array2 As Variant
	If (IsArray(a1)) Then
		array1 = a1
	Else
		If (IsEmpty(a1)) Then
			If (IsArray(a2)) Then
				arrayAdd = a2
			Else
				ReDim array2(0)
				If (IsObject(a2)) Then
					Set array2(0) = a2
				Else
					array2(0) = a2
				End If
				arrayAdd = array2
			End If
			Exit Function
		End If
		ReDim array1(0)
		If (IsObject(a1)) Then
			Set array1(0) = a1
		Else
			array1(0) = a1
		End If
	End If
	If (IsArray(a2)) Then
		array2 = a2
	Else
		If (IsEmpty(a2)) Then
			If (IsArray(a1)) Then
				arrayAdd = a1
			Else
				ReDim array1(0)
				If (IsObject(a1)) Then
					Set array1(0) = a1
				Else
					array1(0) = a1
				End If
				arrayAdd = array1
			End If
			Exit Function
		End If
		ReDim array2(0)
		If (IsObject(a2)) Then
			Set array2(0) = a2
		Else
			array2(0) = a2
		End If
	End If
	arrayAdd = ArrayAppend(array1, array2)
End Function

Open in new window

0
 

Author Comment

by:fdemello
ID: 36715059
Let me give the above a try.  Re: Roles
The Role (which I have subsequently added ) does not solve this problem - unless I'm missing something. I have many databases I need to make sure a specific user has access to all of it's forms & views.  Unless I am mistaken I have to create the Role and add it manually to each form/view.  If I have to do that it's not different than going into 50+ views to manually add the User.  Again - unless I'm missing something.  Hence the thought around using an agent.
Also I am in Asia and the server is in the US and the time it takes to add access to each form/view access is iterminable

Please correct me if I am missing something - Frank
 
0
 
LVL 22

Accepted Solution

by:
Bill-Hanson earned 500 total points
ID: 36716821
First, there's nothing wrong with scripting this the way we are planning.  But for completeness, I'll explain a bit about how roles are used in Lotus land.

RE: "Roles"

Unless you have a different view for each user, you've got it a bit wrong.  You add the role name(s) to the form(s) or view(s) only once - at design time.  Then, when you add a user name to an ACL, you just check the role name(s) to enable access to the form(s) and view(s) for that user.  Once roles are setup, you never have to worry about them again.  My role names usually describe what type of access the role is granting (ie: [ViewAll], [EditAll], [EditProfiles], [ViewReports], etc).

For example, in your question above, you said: "You would think Notes would give a Manager default access to all views but it does not".  Well, a person may need to be able to edit the ACL to grant access to another user, but not have access to particular data in the application (such as salary information or SSNs).  The correct way to handle this in Lotus land is to add the role [Manager] to all manager design elements (views, forms, etc).  Then in the ACL, just enable the [Manager] role when you add a new manager.

If you do have a different view for each user, I would have to ask why?  Seems like a waste of resources.

RE: "Also I am in Asia and the server is in the US and the time it takes to add access to each form/view access is iterminable"

You should not be making design changes to a live application.  Instead, you should be making changes to an empty design template stored on your local machine (you can easily create a design template from a live app).  Then, just refresh the design on the live server when you have finished testing.

This does 2 things for you: 1) Design work goes much, much faster since you are working locally.  2) You have a separate environment for testing your changes before pushing them out to the live server.

I use 3 environments: DEV, TEST, and LIVE.  My developers and I are the only ones with access to the DEV server and design work is done in local replicas.  All users have access to the TEST server, but only testers have access to the test applications.  Of course LIVE needs no explanation.  The design templates are setup so that changes must flow through TEST in order to get to LIVE (ie:  DEV ---> TEST ---> LIVE).
0
 

Author Closing Comment

by:fdemello
ID: 36812910
Thanks Bill
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now