Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / January 2005

Tip: Looking for answers? Try searching our database.

Creating Groups in AD

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jason - 28 Jan 2005 17:14 GMT
I am trying to write code that creates groups in AD using the DirectoryEntry
object in .NET. (I used to be able to do this easily using VBScript...)

Anyways, the following code throws a VEY generic (and unhelpful) error
message. The most obvious reason is that I am not setting some required
property but I have no clue which property that may be. I cannot seem to
find any samples on how to manipulate groups (only on how to work with
users).

entry = New DirectoryEntry("LDAP://ou=MyGroups,dc=mydomain,dc=com")
group = entry.Children.Add("cn=test", "Group")
group.CommitChanges()

The exception thrown is "A constraint violation occurred".

Thanks,
Jason
D_longhorn - 28 Jan 2005 19:59 GMT
Search for active directory and vb.net on google and you will find few
articles that will help.

> I am trying to write code that creates groups in AD using the DirectoryEntry
> object in .NET. (I used to be able to do this easily using VBScript...)
[quoted text clipped - 13 lines]
> Thanks,
> Jason
Jason - 28 Jan 2005 20:40 GMT
I have already tried doing google searches but did so again with your
suggested criteria. No help. Have yet to find a single article on how to
create a group or what the minimum required fields are when creating said
group.

- Jason

> Search for active directory and vb.net on google and you will find few
> articles that will help.
[quoted text clipped - 17 lines]
>> Thanks,
>> Jason
Willy Denoyette [MVP] - 29 Jan 2005 18:06 GMT
This should work unless there is a privilege constraint, the user
credentials used to bind are those of the current user.
Therefore I suggest you execute the same code using explicit credentials of
a domain admin.

Willy.

>I am trying to write code that creates groups in AD using the
>DirectoryEntry object in .NET. (I used to be able to do this easily using
[quoted text clipped - 14 lines]
> Thanks,
> Jason
Marc Scheuner [MVP ADSI] - 31 Jan 2005 08:16 GMT
>I am trying to write code that creates groups in AD using the DirectoryEntry
>object in .NET. (I used to be able to do this easily using VBScript...)
[quoted text clipped - 4 lines]
>
>The exception thrown is "A constraint violation occurred".

You also need to set at least the mandatory attributes, which includes
"sAMAccountName" !

entry = New DirectoryEntry("LDAP://ou=MyGroups,dc=mydomain,dc=com")
group = entry.Children.Add("cn=test", "Group")
group.Properties["sAMAccountName"].Value = "test";
group.CommitChanges()

Also, be aware that the SAM account name needs to be UNIQUE in your
domain! If it's not unique, the creation will fail.

Marc

================================================================
Marc Scheuner                        May The Source Be With You!
Berne, Switzerland                      m.scheuner -at- inova.ch
Jason - 31 Jan 2005 14:32 GMT
Thanks Marc. That was it.

- Jason

> >I am trying to write code that creates groups in AD using the
> >DirectoryEntry
[quoted text clipped - 22 lines]
> Marc Scheuner                        May The Source Be With You!
> Berne, Switzerland                      m.scheuner -at- inova.ch

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.