/// <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)); }
public static async Task <IUser[]> GetUsersInGroupAsync(string groupName) { // validate input parameters ParameterValidator.AssertIsNotNullOrWhiteSpace("groupName", groupName); return(await GetUsersInGroupsAsync(new[] { groupName }, QueryBehaviour.All)); }
public static string GetEmailAddressByNetworkName(string networkName) { ParameterValidator.AssertIsNotNullOrWhiteSpace("networkName", networkName); var filteredNetworkName = PrincipalHelper.TrimDomain(networkName); return(GetActiveDirectoryPropertyValue("sAMAccountName", filteredNetworkName, "mail")); }
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))); }
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))); }
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))); }
/// <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); }
public static string GetNetworkNameByEmailAddress(string emailAddress) { ParameterValidator.AssertIsNotNullOrWhiteSpace("emailAddress", emailAddress); return(GetActiveDirectoryPropertyValue("mail", emailAddress, "sAMAccountName")); }
public static string GetDisplayNameByEmailAddress(string emailAddress) { ParameterValidator.AssertIsNotNullOrWhiteSpace("emailAddress", emailAddress); return(GetActiveDirectoryPropertyValue("mail", emailAddress, "displayname")); }
public static string GetEmailAddressByDisplayName(string displayName) { ParameterValidator.AssertIsNotNullOrWhiteSpace("displayName", displayName); return(GetActiveDirectoryPropertyValue("displayname", displayName, "mail")); }