Creat New Security Group At AD
-
Hi, I'm trying to add new group, but getting an error: error (0x80005000) this is my code-
/// <summary> /// Creates a new group in Active Directory /// </summary> /// <param name="sOU">The OU location you want to save your new Group</param> /// <param name="sGroupName">The name of the new group</param> /// <param name="sDescription">The description of the new group</param> /// <param name="oGroupScope">The scope of the new group</param> /// <param name="bSecurityGroup">True is you want this group /// to be a security group, false if you want this as a distribution group</param> /// <returns>Returns the GroupPrincipal object</returns> public GroupPrincipal CreateNewGroup(string sOU, string sGroupName, string sDescription, GroupScope oGroupScope, bool bSecurityGroup) { PrincipalContext oPrincipalContext = GetPrincipalContext(sOU); GroupPrincipal oGroupPrincipal = new GroupPrincipal(oPrincipalContext, sGroupName); oGroupPrincipal.Description = sDescription; oGroupPrincipal.GroupScope = oGroupScope; oGroupPrincipal.IsSecurityGroup = bSecurityGroup; oGroupPrincipal.Save(); return oGroupPrincipal; } /// <summary> /// Gets the principal context on specified OU /// </summary> /// <param name="sOU">The OU you want your Principal Context to run on</param> /// <returns>Returns the PrincipalContext object</returns> public PrincipalContext GetPrincipalContext(string sOU) { PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Domain, sDomain, sOU, ContextOptions.SimpleBind, sServiceUser, sServicePassword); return oPrincipalContext; }
The code thaken from here- Everything in Active Directory via C#.NET 3.5 (Using System.DirectoryServices.AccountManagement)[^] i think the error comming from here-GroupPrincipal oGroupPrincipal = new GroupPrincipal(oPrincipalContext, sGroupName);
what i'm doing wrong? :( -
Hi, I'm trying to add new group, but getting an error: error (0x80005000) this is my code-
/// <summary> /// Creates a new group in Active Directory /// </summary> /// <param name="sOU">The OU location you want to save your new Group</param> /// <param name="sGroupName">The name of the new group</param> /// <param name="sDescription">The description of the new group</param> /// <param name="oGroupScope">The scope of the new group</param> /// <param name="bSecurityGroup">True is you want this group /// to be a security group, false if you want this as a distribution group</param> /// <returns>Returns the GroupPrincipal object</returns> public GroupPrincipal CreateNewGroup(string sOU, string sGroupName, string sDescription, GroupScope oGroupScope, bool bSecurityGroup) { PrincipalContext oPrincipalContext = GetPrincipalContext(sOU); GroupPrincipal oGroupPrincipal = new GroupPrincipal(oPrincipalContext, sGroupName); oGroupPrincipal.Description = sDescription; oGroupPrincipal.GroupScope = oGroupScope; oGroupPrincipal.IsSecurityGroup = bSecurityGroup; oGroupPrincipal.Save(); return oGroupPrincipal; } /// <summary> /// Gets the principal context on specified OU /// </summary> /// <param name="sOU">The OU you want your Principal Context to run on</param> /// <returns>Returns the PrincipalContext object</returns> public PrincipalContext GetPrincipalContext(string sOU) { PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Domain, sDomain, sOU, ContextOptions.SimpleBind, sServiceUser, sServicePassword); return oPrincipalContext; }
The code thaken from here- Everything in Active Directory via C#.NET 3.5 (Using System.DirectoryServices.AccountManagement)[^] i think the error comming from here-GroupPrincipal oGroupPrincipal = new GroupPrincipal(oPrincipalContext, sGroupName);
what i'm doing wrong? :( -
Hi, I'm trying to add new group, but getting an error: error (0x80005000) this is my code-
/// <summary> /// Creates a new group in Active Directory /// </summary> /// <param name="sOU">The OU location you want to save your new Group</param> /// <param name="sGroupName">The name of the new group</param> /// <param name="sDescription">The description of the new group</param> /// <param name="oGroupScope">The scope of the new group</param> /// <param name="bSecurityGroup">True is you want this group /// to be a security group, false if you want this as a distribution group</param> /// <returns>Returns the GroupPrincipal object</returns> public GroupPrincipal CreateNewGroup(string sOU, string sGroupName, string sDescription, GroupScope oGroupScope, bool bSecurityGroup) { PrincipalContext oPrincipalContext = GetPrincipalContext(sOU); GroupPrincipal oGroupPrincipal = new GroupPrincipal(oPrincipalContext, sGroupName); oGroupPrincipal.Description = sDescription; oGroupPrincipal.GroupScope = oGroupScope; oGroupPrincipal.IsSecurityGroup = bSecurityGroup; oGroupPrincipal.Save(); return oGroupPrincipal; } /// <summary> /// Gets the principal context on specified OU /// </summary> /// <param name="sOU">The OU you want your Principal Context to run on</param> /// <returns>Returns the PrincipalContext object</returns> public PrincipalContext GetPrincipalContext(string sOU) { PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Domain, sDomain, sOU, ContextOptions.SimpleBind, sServiceUser, sServicePassword); return oPrincipalContext; }
The code thaken from here- Everything in Active Directory via C#.NET 3.5 (Using System.DirectoryServices.AccountManagement)[^] i think the error comming from here-GroupPrincipal oGroupPrincipal = new GroupPrincipal(oPrincipalContext, sGroupName);
what i'm doing wrong? :(Chances are you passed in an invalid ADS pathname to one of your functions.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Chances are you passed in an invalid ADS pathname to one of your functions.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
System.DirectoryServices.AccountManagement.PrincipalOperationException was caught Message=Unknown error (0x80005000) Source=System.DirectoryServices.AccountManagement ErrorCode=-2147463168