ActiveDirectoryAuthorization.Services.ActiveDirectoryAuthenticationService.GetAuthenticatedUser C# (CSharp) Метод

GetAuthenticatedUser() публичный Метод

Overrides the default behaviour to return an instance of ActiveDirectoryUser based on the current user in the context if a UserPart hasn't been created for the active directory user yet.
public GetAuthenticatedUser ( ) : IUser
Результат IUser
        public IUser GetAuthenticatedUser()
        {
            if (HttpContext.Current == null || HttpContext.Current.User == null)
                return null;
            
            // attempts to get the user from the UserPart data store if it wasn't previously set.
            if (_authenticatedUser == null)
                _authenticatedUser = _membershipService.Value.GetUser(HttpContext.Current.User.Identity.Name);

            // if the user wasn't previously set, and doesn't exist in the UserPart data store, then the
            // current active directory user is returned instead.
            if (_authenticatedUser == null)
                return new ActiveDirectoryUser();
            // return previously set user, or the user fetched from the data store.
            return _authenticatedUser;
        }
    }