public static void LogOn(IIdentity identity) { OfaIdentity customIdentity = OfaIdentity.GetIdentity(identity); OfaPrincipal customPrincipal = new OfaPrincipal(customIdentity); SetPrincipal(customPrincipal); }
internal static async Task <OfaIdentity> GetIdentityAsync(string networkName) { var user = await ActiveDirectoryHelper.GetUserAsync(networkName); var directReports = await ActiveDirectoryHelper.GetDirectReportsAsync(networkName); var result = new OfaIdentity((IIdentity)user) { GivenName = user.GivenName, Surname = user.Surname, FullName = user.DisplayName, Title = user.Title, Department = user.Department, PhoneNumber = user.TelephoneNumber, EmailAddress = user.Email, Manager = PrincipalHelper.PrependDomain(user.ManagerNetworkName), DirectReports = directReports.Select(o => PrincipalHelper.PrependDomain(o.NetworkName)).ToCollection() }; result.IsManager = result.DirectReports.Any(); result.Roles = user.MemberOf.ToCollection(); return(result); }
public bool IsInRole(string role) { bool result = false; OfaIdentity identity = (OfaIdentity)this.Identity; result = identity.IsInRole(role); return(result); }
public static OfaPrincipal GetPrincipal(string networkName) { OfaIdentity customIdentity = OfaIdentity.GetIdentityAsync(networkName).Result; return(new OfaPrincipal(customIdentity)); }