Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Get connected user group
System
Hi all, could it be possible to get the group in which the connected user is using EditProfile.nrs?
Thanks in advance
Javi
Find more posts tagged with
Comments
jny
Do you mean the group to which the current user belongs? Or the GroupACLs in the edit profile security dialog?
The former would require getting the current session and database, then get the user object to check whether the user is a member to some groups:
[editprof.nrs]
Sub EditProfileDlg_OnInitDialog(dlg)
dim sess, db, usr, grp, grps, sgrps
set db = dlg.GetAttributeByID(0)
set sess = db.Session
set usr = db.GetUser(sess.UserID)
set grps = usr.Groups
msgbox grps.Count
for each grp in grps
sGrps = sGrps & ", " & grp.Name
next
msgbox sGrps
End Sub
If it's the latter, you should be able to get the group using the Document Property off of the dialog object, like so:
[editprof.nrs]
Sub EditProfileDlg_OnInitDialog(dlg)
dim doc, sec, grpacls
set doc = dlg.NRTDocument
set sec = doc.Security
set grpacls = sec.GroupACLs
msgbox grpacls.Count
End Sub
If it's something else, please explain in more details. Perhaps, include a use case scenario.
Migrateduser
Hi, my question was not related with security, it is easier...or not....
I only want to set a custom field as read only depending the users group, the user connected belong.
I.e.: Javi belongs to Lawers group, and in the edit profile dialog a bool checkbox is read only if I don't belong to that group.
Thanks a lot for your help
Javi
Migrateduser
Dear jny, I have just tested the first one, and I think it what I need for my porpouse, because you can get the groups, and depending these values I can set the profile fields.
Thanks again
Javi
Migrateduser
Hi all, I'm having one more problem....
As I told you, the first nrs works perfectly, I have done this for documents as a test:
[EdifProf.nrs]
Const nrtCustom25 = 49
Sub EditProfileDlg_OnInitDialog(dlg)
dim sess, db, usr, grp, grps, sgrps
set db = dlg.GetAttributeByID(0)
set sess = db.Session
set usr = db.GetUser(sess.UserID)
set grps = usr.Groups
dim isAdmin
isAdmin = "False"
for each grp in grps
sGrps = grp.Name
If sGrps = "NRTADMIN" Then
isAdmin = "True"
End if
next
If isAdmin = "False" Then
dlg.SetAttributeValueByID nrtCustom25,,false
End if
End Sub
However, I have to use this for workspaces...so If I try:
[EditWorkspace.nrs]
Const nrtCustom25 = 49
Sub ImanEditWorkspaceDlg_OnInitDialog(dlg)
dim sess, db, usr, grp, grps, sgrps
set db = dlg.GetAttributeByID(0)
set sess = db.Session
set usr = db.GetUser(sess.UserID)
set grps = usr.Groups
dim isAdmin
isAdmin = "False"
for each grp in grps
sGrps = grp.Name
If sGrps = "NRTADMIN" Then
isAdmin = "True"
End if
next
If isAdmin = "False" Then
dlg.SetAttributeValueByID nrtCustom25,,false
End if
End Sub
I get an error as "Object Requiered dlg.GetAttributeByID(...)'"
Any idea?
Regards
Javi
jny
It appears that the GetAttributeID Method does not return any values. This could be a bug.
It should work when you get the database through the workspace object, like so:
dim ws
set ws = dlg.IManWorkspace
set db = ws.Database
Migrateduser
Hi jny, With the new way of getting the db name it works perfectly!!
dim ws
set ws = dlg.IManWorkspace
set db = ws.Database
set sess = db.Session
....
Thanks Million, again
Javi