Click here to Skip to main content
15,879,239 members
Articles / Programming Languages / Visual Basic
Article

Updating Windows Security Groups using VB.NET and Directory Services

Rate me:
Please Sign up or sign in to vote.
4.09/5 (12 votes)
22 Dec 2004 65.9K   608   37   5
How to use directory services to manage group level security. Easily Add, Remove and List users in a Windows domain security group. Note: You must be a Domain Admin to use this code.

Image 1

Introduction

Do you use Integrated Windows Security to manage permissions in your applications and or databases? The class AD_Group.vb provided in this sample project will let you easily Add, Remove and List users in a Windows group. My development group uses group security in our ASP.NET applications using the User.IsInRole ("Domain\Group") function all the time. We also set permissions to our web directories at the group level. Now we manage our groups easily with VB.NET code. It's a lot quicker than logging on to our DC server and using the Active Directory GUI provided in Windows Server 2000. The Windows application pictured below is one way I put the AD_Group.vb class to good use.

To use this code, add a reference to the DirectoryServices.dll:

Image 2

After your reference has been added, simply Add Existing Item to your project. Add the AD_Group.vb file contained in this sample project like so:

Image 3

Then you can call the code like this:

VB
Dim Obj AsNew AD_Group(MyDomain, MyServer, MyGroup)
Obj.RemoveUser("UserName")

That's basically it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
Todd is currently working at PA Lumbermens as a .net programmer.

Comments and Discussions

 
Generalwindows authentication Pin
BMWABCD18-Jan-07 11:07
BMWABCD18-Jan-07 11:07 
Questionfinding Domain Name, Server Name & Group Name Pin
Jwalant Natvarlal Soneji21-Dec-05 18:56
Jwalant Natvarlal Soneji21-Dec-05 18:56 
Generalaccess denied Pin
firstmaster27-Oct-05 15:56
firstmaster27-Oct-05 15:56 
GeneralRe: access denied Pin
ToddHileHoffer29-Oct-05 14:35
ToddHileHoffer29-Oct-05 14:35 
GeneralSecurity Pin
Pradeep Panzade20-Feb-05 18:04
Pradeep Panzade20-Feb-05 18:04 
How to give security i.e permissions to specific folder for specific user using .net classes.

pradeepvpanzade@aesics.ac.in

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.