C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Active Directory »

Group Object in Active Directory


Posted Date: 06 Aug 2009    Resource Type: Code Snippets    Category: Active Directory
Author: Shunmuganathan MMember Level: Diamond    
Rating: 1 out of 5Points: 8



Description :


We can create a Group Object in Active Directory.

Following are the namespaces used


using System.DirectoryServices;
using System.Reflection;


 
public class ADGroup
{

private String ADGRPOUP = "group";

enum GrpType : uint
{
UnivGrp = 0x08,
DomLocalGrp = 0x04,
GlobalGrp = 0x02,
SecurityGrp = 0x80000000
}

DirectoryEntry MyDirectoryEntry = new DirectoryEntry("LDAP://RootDSE");
String Mystr = (String) MyDirectoryEntry.Properties["defaultNamingContext"][0];
MydeAD = new DirectoryEntry("LDAP://" + Mystr);
GrpType Mygt = GrpType.GlobalGrp | GrpType.SecurityGrp;
int MytypeNum = (int)Mygt;
DirectoryEntry Myou = MydeAD.Children.Find("OU=Users");
DirectoryEntry Mygroup = Myou.Children.Add("cn=myGroupName", ADGRPOUP );
Mygroup.Properties["sAMAccountName"].Add("myGroupName");
Mygroup.Properties["description"].Add(" description myGroupName");
Mygroup.Properties["groupType"].Add(typeNum);
Mygroup.CommitChanges();
}



By
Nathan



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Group Object in Active Directory  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: get in file information of a directory
Previous Resource: Export Active Directory user using VBS
Return to Discussion Resource Index
Post New Resource
Category: Active Directory


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use