Tuesday, 15 February 2011

Create Active Directory Group using C# -


I am creating a web app to manage an Active Directory. I want to create a group in a fixed container.

  var group = new list & lt; Model Groups & gt; (); Principal Consultx CTX = New Principal Consort (ContaxType Domain, Domain, Container, Username, Password); Group Principal Og Group Principal = New Group Principal (CTX); OGroupPrincipal.Description = mGroup.GroupName; O Group Principal. Group Scope = MGUP Group scope; OGroupPrincipal.IsSecurityGroup = mGroup.IsSecurity; OGroupPrincipal.Save ();   

But I get the following error:

The 'string' for the system 'directory services' can not be converted mutually. AccountManagement.GroupScope? '

I'm not sure how to manage it.

I also get this error:

SamAccountName or name should be assigned. How should I group group groups from the group into the scope? A newly created Principal Object & gt; Before saving

The area of ​​the group is an enum with values ​​of local, global and universal, it seems that you have not left the incoming value .

Try setting this to a fixed value:

  oGroupPrincipal.GroupScope = System.DirectoryServices.AccountManagement.GroupScope is local;   

If this clears the error, try parsing your incoming string:

  oGroupPrincipal.GroupScope = (System.DirectoryServices.AccountManagement. GroupScope) Enum.Parse (typeof (System.DirectoryServices.AccountManagement.GroupScope), value);    

No comments:

Post a Comment