Пример #1
0
        /// <summary>
        /// Find group with given name, if not exists create
        /// </summary>
        /// <param name="role">Group name</param>
        /// <returns>Group DirectorEntry</returns>
        internal static DirectoryEntry FindGroupIfNotExistsCreate(WCSSecurityRole role)
        {
            try
            {
                DirectoryEntry AD  = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
                DirectoryEntry grp = AD.Children.Find(role.ToString(), "group");
                if (grp == null)
                {
                    ChassisManagerUtil.CreateNewGroup(role);
                }

                return(grp);
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                Tracer.WriteInfo(" Group: {0} not found , creating new", role.ToString());
                return(ChassisManagerUtil.CreateNewGroup(role));
            }
        }