コード例 #1
0
        /// <summary>
        /// Converts the specified string value to its corresponding enumeration.
        /// </summary>
        /// <typeparam name="T">The enum type.</typeparam>
        /// <param name="value">The enum value.</param>
        /// <param name="ignoreCase">A flag indicating whether or not to ignore the case of the enum value.</param>
        /// <returns>An enumeration of the specified type.</returns>
        public static T Parse <T>(string value, bool ignoreCase)
        {
            ParameterValidator.AssertIsEnum <T>();
            ParameterValidator.AssertIsNotNullOrWhiteSpace("value", value);

            return((T)Enum.Parse(typeof(T), value, ignoreCase));
        }
コード例 #2
0
        public static async Task <IUser[]> GetUsersInGroupAsync(string groupName)
        {
            // validate input parameters

            ParameterValidator.AssertIsNotNullOrWhiteSpace("groupName", groupName);

            return(await GetUsersInGroupsAsync(new[] { groupName }, QueryBehaviour.All));
        }
コード例 #3
0
        public static string GetEmailAddressByNetworkName(string networkName)
        {
            ParameterValidator.AssertIsNotNullOrWhiteSpace("networkName", networkName);

            var filteredNetworkName = PrincipalHelper.TrimDomain(networkName);

            return(GetActiveDirectoryPropertyValue("sAMAccountName", filteredNetworkName, "mail"));
        }
コード例 #4
0
        public static async Task <IUser[]> GetManagersAsync(string userName)
        {
            // validate input parameters
            ParameterValidator.AssertIsNotNullOrWhiteSpace("userName", userName);

            var client = GetUsersClient();

            return((IUser[])await client.Execute(o => o.GetManagersAsync(userName, int.MaxValue)));
        }
コード例 #5
0
        public static async Task <IUser> GetContactAsync(string email)
        {
            // validate input parameters
            ParameterValidator.AssertIsNotNullOrWhiteSpace("email", email);

            // return a list of users within the specified group
            var client = GetUsersClient();

            return((IUser)await client.Execute(o => o.GetContactByEmailAsync(email)));
        }
コード例 #6
0
        public static async Task <IUser> GetUserAsync(string userName)
        {
            // validate input parameters
            ParameterValidator.AssertIsNotNullOrWhiteSpace("userName", userName);

            // return a list of users within the specified group
            var client = GetUsersClient();

            return((IUser)await client.Execute(o => o.GetUserAndRolesAsync(userName, SearchDepth.Nested)));
        }
コード例 #7
0
        /// <summary>
        /// Scans Description values of an enum, returning matched elements
        /// </summary>
        /// <typeparam name="T">The enum type.</typeparam>
        /// <param name="description">The enum description.</param>
        /// <returns>An enumeration of the specified type.</returns>
        public static IEnumerable <T> GetForDescription <T>(string description)
        {
            ParameterValidator.AssertIsEnum <T>();
            ParameterValidator.AssertIsNotNullOrWhiteSpace("description", description);

            Type                    enumType   = typeof(T);
            Collection <T>          enums      = new Collection <T>();
            IEnumerable <FieldInfo> fieldInfos = enumType.GetFields().Where(o => o.FieldType == enumType);

            foreach (FieldInfo fieldInfo in fieldInfos)
            {
                DescriptionAttribute attribute = fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault() as DescriptionAttribute;

                if (attribute != null && attribute.Description == description)
                {
                    T enumFieldValue = (T)fieldInfo.GetValue(default(T));

                    enums.Add(enumFieldValue);
                }
            }

            return(enums);
        }
コード例 #8
0
        public static string GetNetworkNameByEmailAddress(string emailAddress)
        {
            ParameterValidator.AssertIsNotNullOrWhiteSpace("emailAddress", emailAddress);

            return(GetActiveDirectoryPropertyValue("mail", emailAddress, "sAMAccountName"));
        }
コード例 #9
0
        public static string GetDisplayNameByEmailAddress(string emailAddress)
        {
            ParameterValidator.AssertIsNotNullOrWhiteSpace("emailAddress", emailAddress);

            return(GetActiveDirectoryPropertyValue("mail", emailAddress, "displayname"));
        }
コード例 #10
0
        public static string GetEmailAddressByDisplayName(string displayName)
        {
            ParameterValidator.AssertIsNotNullOrWhiteSpace("displayName", displayName);

            return(GetActiveDirectoryPropertyValue("displayname", displayName, "mail"));
        }