public IApplicationInformation GetApplicationById(string id)
        {
            var _client = this.GetActiveDirectoryClient();
            ApplicationInformation _appInfo = null;

            try
            {
                var _aadApplications = _client.Applications.
                                       Where(app => app.AppId.Equals(id))
                                       .ExecuteAsync()
                                       .Result
                                       .CurrentPage.ToList();

                // should only find one with the id
                if (_aadApplications != null && _aadApplications.Count == 1)
                {
                    var _azureApplication = _aadApplications.First();

                    if (_azureApplication != null)
                    {
                        _appInfo = new ApplicationInformation
                        {
                            AppId          = _azureApplication.AppId,
                            DiplayName     = _azureApplication.DisplayName,
                            ReplyUrls      = _azureApplication.ReplyUrls,
                            IdentifierUris = _azureApplication.IdentifierUris
                        };

                        if (_azureApplication.PasswordCredentials.Count != 0)
                        {
                            _appInfo.EndDate = _azureApplication.PasswordCredentials.FirstOrDefault().EndDate;
                        }

                        if (_azureApplication.KeyCredentials.Count != 0)
                        {
                            _appInfo.EndDate = _azureApplication.KeyCredentials.FirstOrDefault().EndDate;
                        }
                    }
                }

                return(_appInfo);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public List <IApplicationInformation> GetAllApplications()
        {
            List <IApplicationInformation> _applications = new List <IApplicationInformation>();
            var _client = this.GetActiveDirectoryClient();

            IPagedCollection <IApplication> _azureApplications = null;

            try
            {
                _azureApplications = _client.Applications.Take(999).ExecuteAsync().Result;
                if (_azureApplications != null)
                {
                    foreach (var _azureApp in _azureApplications.CurrentPage.ToList())
                    {
                        var _appInfo = new ApplicationInformation
                        {
                            AppId          = _azureApp.AppId,
                            DiplayName     = _azureApp.DisplayName,
                            ReplyUrls      = _azureApp.ReplyUrls,
                            IdentifierUris = _azureApp.IdentifierUris
                        };


                        if (_azureApp.PasswordCredentials.Count != 0)
                        {
                            _appInfo.EndDate = _azureApp.PasswordCredentials.FirstOrDefault().EndDate;
                        }

                        if (_azureApp.KeyCredentials.Count != 0)
                        {
                            _appInfo.EndDate = _azureApp.KeyCredentials.FirstOrDefault().EndDate;
                        }
                        _applications.Add(_appInfo);
                    }
                }

                return(_applications);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #3
0
        public List<IApplicationInformation> GetAllApplications()
        {
            List<IApplicationInformation> _applications = new List<IApplicationInformation>();
            var _client = this.GetActiveDirectoryClient();

            IPagedCollection<IApplication> _azureApplications = null;

            try
            {
                _azureApplications = _client.Applications.Take(999).ExecuteAsync().Result;
                if(_azureApplications != null)
                {
                    foreach(var _azureApp in _azureApplications.CurrentPage.ToList())
                    {
                        var _appInfo = new ApplicationInformation
                        {

                            AppId = _azureApp.AppId,
                            DiplayName = _azureApp.DisplayName,
                            ReplyUrls = _azureApp.ReplyUrls,
                            IdentifierUris = _azureApp.IdentifierUris
                        };

                        if(_azureApp.PasswordCredentials.Count != 0) {
                            _appInfo.EndDate = _azureApp.PasswordCredentials.FirstOrDefault().EndDate;
                        }

                        if(_azureApp.KeyCredentials.Count != 0) {
                            _appInfo.EndDate = _azureApp.KeyCredentials.FirstOrDefault().EndDate;
                        }
                        _applications.Add(_appInfo);
                    }
                }

                return _applications;

            }
            catch(Exception ex)
            {
                throw;
            }
        }
        public IList <IApplicationInformation> GetExpiredApplicationInDays(double numberOfDays)
        {
            List <IApplicationInformation> _applications = new List <IApplicationInformation>();
            var _client = this.GetActiveDirectoryClient();
            IPagedCollection <IApplication> _azureApplications = null;

            try
            {
                _azureApplications = _client.Applications.Take(999).ExecuteAsync().Result;
                if (_azureApplications != null)
                {
                    List <IApplication> _apps = _azureApplications.CurrentPage.Where(x => x.PasswordCredentials.Count > 0).ToList();
                    //var _expiredApps = _apps.Where(x => x.PasswordCredentials.FirstOrDefault().EndDate >= DateTime.Now || x.KeyCredentials.FirstOrDefault().EndDate >= DateTime.Now &&
                    //        x.KeyCredentials.FirstOrDefault().EndDate <= DateTime.Now.AddDays(numberOfDays) ||
                    //        x.PasswordCredentials.FirstOrDefault().EndDate <= DateTime.Now.AddDays(numberOfDays)).ToList();

                    var _expiredApps = _apps.Where(x => x.PasswordCredentials.FirstOrDefault().EndDate >= DateTime.Now && x.PasswordCredentials.FirstOrDefault().EndDate <= DateTime.Now.AddDays(numberOfDays)).ToList();
                    foreach (var _expiredApp in _expiredApps)
                    {
                        var _appInfo = new ApplicationInformation
                        {
                            AppId          = _expiredApp.AppId,
                            DiplayName     = _expiredApp.DisplayName,
                            ReplyUrls      = _expiredApp.ReplyUrls,
                            IdentifierUris = _expiredApp.IdentifierUris
                        };

                        if (_expiredApp.PasswordCredentials.Count != 0)
                        {
                            _appInfo.EndDate = _expiredApp.PasswordCredentials.FirstOrDefault().EndDate;
                        }

                        _applications.Add(_appInfo);
                    }
                }
                return(_applications);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #5
0
        public IList<IApplicationInformation> GetExpiredApplicationInDays(double numberOfDays)
        {
            List<IApplicationInformation> _applications = new List<IApplicationInformation>();
            var _client = this.GetActiveDirectoryClient();
            IPagedCollection<IApplication> _azureApplications = null;

            try
            {
                _azureApplications = _client.Applications.Take(999).ExecuteAsync().Result;
                if (_azureApplications != null)
                {
                    List<IApplication> _apps = _azureApplications.CurrentPage.Where(x => x.PasswordCredentials.Count > 0).ToList();
                    //var _expiredApps = _apps.Where(x => x.PasswordCredentials.FirstOrDefault().EndDate >= DateTime.Now || x.KeyCredentials.FirstOrDefault().EndDate >= DateTime.Now &&
                    //        x.KeyCredentials.FirstOrDefault().EndDate <= DateTime.Now.AddDays(numberOfDays) ||
                    //        x.PasswordCredentials.FirstOrDefault().EndDate <= DateTime.Now.AddDays(numberOfDays)).ToList();

                    var _expiredApps = _apps.Where(x => x.PasswordCredentials.FirstOrDefault().EndDate >= DateTime.Now  &&  x.PasswordCredentials.FirstOrDefault().EndDate <= DateTime.Now.AddDays(numberOfDays)).ToList();
                    foreach (var _expiredApp in _expiredApps)
                    {
                        var _appInfo = new ApplicationInformation
                        {
                            AppId = _expiredApp.AppId,
                            DiplayName = _expiredApp.DisplayName,
                            ReplyUrls = _expiredApp.ReplyUrls,
                            IdentifierUris = _expiredApp.IdentifierUris
                        };

                        if (_expiredApp.PasswordCredentials.Count != 0)
                        {
                            _appInfo.EndDate = _expiredApp.PasswordCredentials.FirstOrDefault().EndDate;
                        }

                        _applications.Add(_appInfo);
                    }
                }
                return _applications;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #6
0
        public IApplicationInformation GetApplicationById(string id)
        {
            var _client = this.GetActiveDirectoryClient();
            ApplicationInformation _appInfo = null;

            try
            {
                var _aadApplications = _client.Applications.
                    Where(app => app.AppId.Equals(id))
                    .ExecuteAsync()
                    .Result
                    .CurrentPage.ToList();

                // should only find one with the id
                if(_aadApplications != null && _aadApplications.Count == 1)
                {
                    var _azureApplication = _aadApplications.First();

                    if (_azureApplication != null)
                    {
                        _appInfo = new ApplicationInformation
                        {
                            AppId = _azureApplication.AppId,
                            DiplayName = _azureApplication.DisplayName,
                            ReplyUrls = _azureApplication.ReplyUrls,
                            IdentifierUris = _azureApplication.IdentifierUris
                        };

                        if (_azureApplication.PasswordCredentials.Count != 0)
                        {
                            _appInfo.EndDate = _azureApplication.PasswordCredentials.FirstOrDefault().EndDate;
                        }

                        if (_azureApplication.KeyCredentials.Count != 0)
                        {
                            _appInfo.EndDate = _azureApplication.KeyCredentials.FirstOrDefault().EndDate;
                        }
                    }
                }

                return _appInfo;
            }
            catch(Exception ex)
            {
                throw;
            }
        }