VBA - Loop Security Groups for a Specific User -


i have built function checks if user member of security group. loops groups loop user's groups. tried change function keeps giving me type mismatch error.

there securitygroups property object scuser. when use in each loop gives me type mismatch error. for each secgroup in scuser.securitygroups

the code below works fine. how modify loops user's group?

public function userhasaccess(sgroup string) boolean      dim scuser cuser     dim secgroup csecuritygroup     dim secgroups csecuritygroups      set scuser = new cuser     scuser.init sessioncontext     scuser.load sessioncontext.currentuserid      set secgroups = new csecuritygroups     secgroups.init sessioncontext      each secgroup in secgroups          debug.print secgroup.fields(securitygroup_fld_name)          if secgroup.fields(securitygroup_fld_name) = sgroup             userhasaccessnew = true             exit function         end if      next  end function 

i found answer. see below. thank help.

public function userhasaccess(byval groupname) boolean

dim ogroups csecuritygroups dim ogroup csecuritygroup dim osecuser csecurityuser  set ogroups = new csecuritygroups ogroups.init reapplication.sessioncontext  each ogroup in ogroups      if ogroup.fields(securitygroup_fld_name) = groupname          each osecuser in ogroup.securityusers              if trim(osecuser.fields(securityuser_fld_users_id)) = trim(reapplication.sessioncontext.currentuserid)                 userhasaccess = true             end if          next osecuser      end if      ogroup.closedown  next ogroup  ogroups.closedown set ogroups = nothing set ogroup = nothing set osecuser = nothing 

end function


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -