Sys Buddies (I.T. Folks — Helping Each Other)
September 06, 2010, 04:51:36 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Contact Login Register  

Del.icio.us Digg FURL FaceBook Stumble Upon Reddit SlashDot

Pages: [1]
  Print  
Author Topic: VBS ADSI function to check for group membership of a user in Active Directory  (Read 3339 times)
Dave Bauer
Custom Title
Administrator
Newbie
*****
Posts: 26



View Profile
« on: January 22, 2008, 09:54:21 PM »

'I find this handy to use in logins scripts.
'Feed the function the name of the group you want to check for membership of, it will return true if is member
'Example:
   if memberOf("Fred's Friends") then msgbox "Fred says hello!"

function memberOf(groupName)
   set oNet = CreateObject("WScript.Network")
   set oUser = GetObject("WinNT://YourDomainName/" & oNet.UserName & ",user")
   
   ' Enurmerate Groups for the user
   for each oGroup in oUser.Groups
      if ucase(oGroup.Name) = ucase(groupName) then
         memberOf = true
         exit for
      end if
   next
   
   set oUser = nothing
   set oGroup = nothing
   set onet = nothing
end function
Logged

Some days your the bug -- Some days your the windshield
Sys Buddies (I.T. Folks — Helping Each Other)
« on: January 22, 2008, 09:54:21 PM »

 Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks
| Sitemap | Privacy Policy
Valid XHTML 1.0! Valid CSS!