It is not so easy, because you need to count with two cases:
DB User
Windows User
and the second one means that you can be member of group which is member of the role... ;-)
IsMemberOf(UserIDVal : Code[20];RoleID : Code[20]) : Boolean
Var
MemberOf : Record 2000000003
begin
IF MemberOf.GET(UserIDVal,RoleID) THEN
EXIT(TRUE);
EXIT(IsWinMemberOf(UserIDVal,RoleID));
end;
IsWinMemberOf(UserIDVal : Code[20];RoleID : Code[20]) : Boolean
Var
Domain : Record 2000000056
WinMemberOf : Record 2000000053
begin
IF Domain.FIND('-') THEN
REPEAT
IF WinMemberOf.GET(Domain.SID,RoleID,'') THEN
EXIT(TRUE);
UNTIL Domain.NEXT=0;
EXIT(FALSE);
end;
You can use the IsMemberOf function with UserID and RoleID to detect if the user is member of the role, BUT this function works correctly only if the UserID is the ID of the logged in user or ID of some Database User. If you enter ID of another windows user, it will not work correctly, because the virtual tables used in IsWinMemberOf are filled just with records for the logged in Windows User.
Answers
Do a lookup to the "Member Of" table 2000000003
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
You could use the "Member of" (2000000003) table and set a range on the user and role id to see if the user exist for that role.
Hope this helps
Albert
DB User
Windows User
and the second one means that you can be member of group which is member of the role... ;-)
You can use the IsMemberOf function with UserID and RoleID to detect if the user is member of the role, BUT this function works correctly only if the UserID is the ID of the logged in user or ID of some Database User. If you enter ID of another windows user, it will not work correctly, because the virtual tables used in IsWinMemberOf are filled just with records for the logged in Windows User.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!