Solved

lotus notes user group membership

Posted on 2008-10-09
6
3,441 Views
Last Modified: 2013-12-18
How can I determine what groups a lotus notes user belongs to?
0
Comment
Question by:btbsjtremper
6 Comments
 
LVL 20

Assisted Solution

by:brwwiggins
brwwiggins earned 50 total points
ID: 22682714
Open the address book off the server, go to the groups view (from the navigator on the left). Once the view opens click on the "Find Group Member" button and enter the user's name. After the script runs it will list all the groups that the person is a member of
0
 
LVL 63

Assisted Solution

by:SysExpert
SysExpert earned 50 total points
ID: 22683949
Or just use the search bar to do a search by name.


I hope this helps !
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 22686480
Manually or using LotusScript?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:btbsjtremper
ID: 22686796
I'm gonna try it out in a little while I will let you all know the status, thanks for your help
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 22686842
Manually obviously :)
0
 
LVL 22

Accepted Solution

by:
mbonaci earned 150 total points
ID: 22686998
Here's the code that returns all groups the user is member of:
Function GetAllValidGroupsForUser(username As String, server As String, maxdepth As Integer) As Variant

%REM

	This function gets all the groups that a user can belong to.

	This is a RECURSIVE function, so be careful when modifying it.

	MAXDEPTH is used to regulate how far down in group levels it can go.

	If checking ACL groups, 6 is the limit, for mail groups its 20 -- but this can change with Domino versions in the future.

	This sample code is distributed freely with only one obligation. 

	You must distribute this code as a whole, including these comments, if you distribute it or re-use it at all.

	For help, please contact

	andrewp@thenorth.com

	Andrew Pollack

	Northern Collaborative Technologies

%END REM
 

      ' use static variables so that you can avoid repeatedly

      ' getting a handle to the same resources.

      Static nab As notesdatabase

      Static nabview As notesview

      Static userview As notesview

      Static foundlist List As String

      Static depth As Integer
 

      ' since depth is a static variable, each recursive call to this

      ' function will increase its value.  We can also decrease its

      ' value so we know when we're back to the initial call.

      If depth => MAXDEPTH Then Exit Function

      depth = depth + 1
 

      ' check to see if we haven't already connected to the nab & views

      ' if not, connect now.

      If nab Is Nothing Then Set nab = New notesdatabase(server,"NAMES.NSF")

      If nab Is Nothing Then Exit Function

      If nabview Is Nothing Then Set nabview = nab.getview("($ServerAccess)")

      If userview Is Nothing Then Set userview = nab.getview("($Users)")

      If userview Is Nothing Then Exit Function

      If nabview Is Nothing Then Exit Function
 

      ' declarations

      Dim collection As notesdocumentcollection

      Dim doc As notesdocument

      Dim v As Variant

      Dim count As Integer

      Dim usercount As Integer

      Dim alreadyhandlednamevariants As Integer

      Redim usernamelist(0) As String

      Dim tempusernamelist As Variant
 

  ' first set the first username in the list to the current one as called

  ' keep in mind, if this is not the first call, but part of the recursion,

  ' this may be another variant of the name, or the name of a group

      usernamelist(0) = username
 

  ' this section will build an array of all the shortnames and name variants the user has

  ' by checking for a person record in the nab, using that to get the fullname of the user

  ' then calculating all the name variants on that (uses the function getNotesNameVariants)

      Set doc=userview.getdocumentbykey(username, True)

      If Not doc Is Nothing Then

            If doc.form(0) = "Person" Then

                  usercount = 0

                  Forall shortname In doc.fullname

                        Redim Preserve usernamelist(usercount) As String

                        usernamelist(usercount) = shortname

                        ' don't recheck variants if you've already checked the name

                        If Not alreadyhandlednamevariants = 1 Then

                              tempusernamelist = getnotesnamevariants(shortname)

                              'add all the found variants to the list of names to be checked

                              Forall tusername In tempusernamelist

                                    usercount = usercount + 1

                                    Redim Preserve usernamelist(usercount)

                                    usernamelist(usercount) = tusername

                              End Forall

                        End If

                        usercount = usercount +1

                  End Forall

            End If

      End If
 

      ' this is the result that will be returned at the end of the function

      Redim returnlist(0) As String
 

      ' here's the meat of the function

      Forall checkusername In usernamelist 'for each name variant

            If Not checkusername = "" Then ' don't check 'empty' names

                  Set collection = nabview.getalldocumentsbykey(checkusername,True) ' get any groups the name matches

                  If Not collection.count = 0 Then ' if there are any matches

                        Set doc = collection.getfirstdocument

                        While Not doc Is Nothing ' loop through all the matching groups

                              If Not doc.listname(0) = "" Then

                                    If Not Iselement(foundlist(doc.listname(0))) Then

                                          ' use this static list to avoid duplicate calls & infinite loops

                                          foundlist(doc.listname(0)) = "1"

                                          ' look! Here's the recursion! We're calling THIS function again

                                          ' with the new name variant.  It will return the list from this

                                          ' variant.  Deeper and Deeper it goes!

                                          v = getallvalidgroupsforuser(doc.listname(0), server, maxdepth)

                                          If Not Isempty(v) Then

                                                ' add the ones from the last depth to the current list,

                                                ' and prepare to return it to the one that called this one!

                                                Forall group In v

                                                      If Not group = "" Then

                                                            Redim Preserve returnlist(count) As String

                                                            returnlist(count) = group

                                                            count = count + 1

                                                      End If

                                                End Forall

                                          End If

                                          Redim Preserve returnlist(count)

                                          returnlist(count) = doc.listname(0)

                                          count = count + 1

                                    End If

                                    Set doc=collection.getnextdocument(doc)

                              End If

                        Wend

	       End If

            End If

      End Forall
 

      ' whew, now just return the list of all we found, plus all those found by

      ' any recursive calls we made, and the calls they made, and the calls they made, ...

      getallvalidgroupsforuser = returnlist
 

      depth = depth -1

      If depth = 0 Then

    ' this exit will be the last recursion, so delete the static list so we can run again if we need!

            Erase foundlist

      End If

End Function
 
 
 
 

Usage example:
 

Sub Click(Source As Button)

%REM

      Function getallvalidgroupsforuser(username As String, server As String, maxdepth As Integer) As Variant

      This sample code is distributed freely with only one obligation.  

      You must distribute this code as a whole, including these comments, if you distribute it or re-use it at all.

      For help, please contact

	andrewp@thenorth.com

	Andrew Pollack

	Northern Collaborative Technologies

%END REM
 

      ' first, get hold of the current document

      Dim workspace As New notesuiworkspace

      Dim uidoc As notesuidocument

      Dim doc As notesdocument

      Set uidoc = workspace.currentdocument

      Set doc = uidoc.document
 

      ' now try to get the address book we're going to use

      Dim nab As New notesdatabase( doc.server(0),  doc.addressbook(0) )
 

      If nab Is Nothing Then

            Messagebox("Cannot find the address book.")

            Exit Sub

      End If
 

      If Not nab.isopen Then

            Messagebox("Cannot open the address book.")

            Exit Sub

      End If
 

      ' get the varaibles

      Dim username As String

      Dim maxdepth As Integer
 

      username = Inputbox$("For what user?")

      maxdepth = Cint(Inputbox$("How deep should we go?  Usually, 6 for acls and 20 for mail.", "", "6"))
 

      ' make the call

      Dim v As Variant

      v = getallvalidgroupsforuser(username, doc.server(0), maxdepth)
 

      'output the results

      Dim outtxt As String

      outtxt  = "User: " & username & " is in the following groups." & Chr$(13) & Chr$(10) & Chr$(13) & Chr$(10)
 

      Forall entry In v

            outtxt = outtxt & (entry & Chr$(13) & Chr$(10))

      End Forall
 

      doc.display = outtxt
 

End Sub

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

863 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

22 Experts available now in Live!

Get 1:1 Help Now