Пример #1
0
        internal OrganizationUser GetUserGeneralSettingsInternal(string loginName, string organizationId)
        {
            HostedSolutionLog.LogStart("GetUserGeneralSettingsInternal");
            HostedSolutionLog.DebugInfo("loginName : {0}", loginName);
            HostedSolutionLog.DebugInfo("organizationId : {0}", organizationId);

            if (string.IsNullOrEmpty(loginName))
            {
                throw new ArgumentNullException("loginName");
            }

            string         path  = GetUserPath(organizationId, loginName);
            DirectoryEntry entry = ActiveDirectoryUtils.GetADObject(path);

            OrganizationUser retUser = new OrganizationUser();

            retUser.FirstName         = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.FirstName);
            retUser.LastName          = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.LastName);
            retUser.DisplayName       = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.DisplayName);
            retUser.Initials          = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Initials);
            retUser.JobTitle          = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.JobTitle);
            retUser.Company           = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Company);
            retUser.Department        = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Department);
            retUser.Office            = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Office);
            retUser.BusinessPhone     = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.BusinessPhone);
            retUser.Fax               = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Fax);
            retUser.HomePhone         = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.HomePhone);
            retUser.MobilePhone       = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.MobilePhone);
            retUser.Pager             = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Pager);
            retUser.WebPage           = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.WebPage);
            retUser.Address           = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Address);
            retUser.City              = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.City);
            retUser.State             = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.State);
            retUser.Zip               = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Zip);
            retUser.Country           = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Country);
            retUser.Notes             = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Notes);
            retUser.ExternalEmail     = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.ExternalEmail);
            retUser.Disabled          = (bool)entry.InvokeGet(ADAttributes.AccountDisabled);
            retUser.Manager           = GetManager(entry);
            retUser.DomainUserName    = GetDomainName(loginName);
            retUser.DistinguishedName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.DistinguishedName);
            retUser.Locked            = (bool)entry.InvokeGet(ADAttributes.AccountLocked);

            HostedSolutionLog.LogEnd("GetUserGeneralSettingsInternal");
            return(retUser);
        }
Пример #2
0
        private OrganizationUser GetManager(DirectoryEntry entry)
        {
            OrganizationUser retUser = null;
            string           path    = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Manager);

            if (!string.IsNullOrEmpty(path))
            {
                path = ActiveDirectoryUtils.AddADPrefix(path, PrimaryDomainController);
                if (ActiveDirectoryUtils.AdObjectExists(path))
                {
                    DirectoryEntry user = ActiveDirectoryUtils.GetADObject(path);
                    retUser             = new OrganizationUser();
                    retUser.DisplayName = ActiveDirectoryUtils.GetADObjectStringProperty(user, ADAttributes.DisplayName);

                    retUser.AccountName = ActiveDirectoryUtils.GetADObjectStringProperty(user, ADAttributes.Name);
                }
            }

            return(retUser);
        }
 protected static int CompareAccount(OrganizationUser user1, OrganizationUser user2)
 {
     return string.Compare(user1.DisplayName, user2.DisplayName);
 }
        protected void BindAccounts(OrganizationUser[] newUsers, bool preserveExisting)
		{
			// get binded addresses
            List<OrganizationUser> users = new List<OrganizationUser>();
			if(preserveExisting)
                users.AddRange(GetGridViewUsers(SelectedState.All));

			// add new accounts
            if (newUsers != null)
			{
                foreach (OrganizationUser newUser in newUsers)
				{
					// check if exists
					bool exists = false;
                    foreach (OrganizationUser user in users)
					{
                        if (String.Compare(user.AccountName, newUser.AccountName, true) == 0)
						{
							exists = true;
							break;
						}
					}

					if (exists)
						continue;

                    users.Add(newUser);
				}
			}

            gvUsers.DataSource = users.OrderBy(u => u.DisplayName);
            gvUsers.DataBind();
		}
        private OrganizationUser GetManager(DirectoryEntry entry, string adAttribute)
        {
            OrganizationUser retUser = null;
            string path = ActiveDirectoryUtils.GetADObjectStringProperty(entry, adAttribute);
            if (!string.IsNullOrEmpty(path))
            {
                path = ActiveDirectoryUtils.AddADPrefix(path, PrimaryDomainController);
                if (ActiveDirectoryUtils.AdObjectExists(path))
                {
                    DirectoryEntry user = ActiveDirectoryUtils.GetADObject(path);
                    retUser = new OrganizationUser();
                    retUser.DisplayName = ActiveDirectoryUtils.GetADObjectStringProperty(user, ADAttributes.DisplayName);

                    retUser.AccountName = ActiveDirectoryUtils.GetADObjectStringProperty(user, ADAttributes.Name);
                }
            }

            return retUser;
        }
 public void SetFolderOwaAccounts(int itemId, SystemFile folder, OrganizationUser[] users)
 {
     EnterpriseStorageController.SetFolderOwaAccounts(itemId, folder.Name, users);
 }
 private static OrganizationUser GetDemoUserGeneralSettings()
 {
     OrganizationUser user = new OrganizationUser();
     user.DisplayName = "John Smith";            
     user.AccountName = "john_fabrikam";
     user.FirstName = "John";
     user.LastName = "Smith";
     user.AccountType = ExchangeAccountType.Mailbox;            
     return user;
 }
Пример #8
0
 /// <remarks/>
 public void CreateCRMUserAsync(OrganizationUser user, int packageId, int itemId, System.Guid businessUnitOrgId, object userState) {
     if ((this.CreateCRMUserOperationCompleted == null)) {
         this.CreateCRMUserOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateCRMUserOperationCompleted);
     }
     this.InvokeAsync("CreateCRMUser", new object[] {
                 user,
                 packageId,
                 itemId,
                 businessUnitOrgId}, this.CreateCRMUserOperationCompleted, userState);
 }
 /// <remarks/>
 public void SetFolderOwaAccountsAsync(int itemId, SystemFile folder, OrganizationUser[] users, object userState) {
     if ((this.SetFolderOwaAccountsOperationCompleted == null)) {
         this.SetFolderOwaAccountsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetFolderOwaAccountsOperationCompleted);
     }
     this.InvokeAsync("SetFolderOwaAccounts", new object[] {
                 itemId,
                 folder,
                 users}, this.SetFolderOwaAccountsOperationCompleted, userState);
 }
 /// <remarks/>
 public void SetFolderOwaAccountsAsync(int itemId, SystemFile folder, OrganizationUser[] users) {
     this.SetFolderOwaAccountsAsync(itemId, folder, users, null);
 }
 /// <remarks/>
 public System.IAsyncResult BeginSetFolderOwaAccounts(int itemId, SystemFile folder, OrganizationUser[] users, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("SetFolderOwaAccounts", new object[] {
                 itemId,
                 folder,
                 users}, callback, asyncState);
 }
 public void SetFolderOwaAccounts(int itemId, SystemFile folder, OrganizationUser[] users) {
     this.Invoke("SetFolderOwaAccounts", new object[] {
                 itemId,
                 folder,
                 users});
 }
Пример #13
0
 /// <remarks/>
 public void CreateCRMUserAsync(OrganizationUser user, string orgName, System.Guid organizationId, System.Guid baseUnitId, object userState) {
     if ((this.CreateCRMUserOperationCompleted == null)) {
         this.CreateCRMUserOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateCRMUserOperationCompleted);
     }
     this.InvokeAsync("CreateCRMUser", new object[] {
                 user,
                 orgName,
                 organizationId,
                 baseUnitId}, this.CreateCRMUserOperationCompleted, userState);
 }
Пример #14
0
 /// <remarks/>
 public void CreateCRMUserAsync(OrganizationUser user, string orgName, System.Guid organizationId, System.Guid baseUnitId) {
     this.CreateCRMUserAsync(user, orgName, organizationId, baseUnitId, null);
 }
Пример #15
0
 /// <remarks/>
 public System.IAsyncResult BeginCreateCRMUser(OrganizationUser user, string orgName, System.Guid organizationId, System.Guid baseUnitId, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("CreateCRMUser", new object[] {
                 user,
                 orgName,
                 organizationId,
                 baseUnitId}, callback, asyncState);
 }
Пример #16
0
 public UserResult CreateCRMUser(OrganizationUser user, string orgName, System.Guid organizationId, System.Guid baseUnitId) {
     object[] results = this.Invoke("CreateCRMUser", new object[] {
                 user,
                 orgName,
                 organizationId,
                 baseUnitId});
     return ((UserResult)(results[0]));
 }
Пример #17
0
 /// <remarks/>
 public void CreateCRMUserAsync(OrganizationUser user, int packageId, int itemId, System.Guid businessUnitOrgId) {
     this.CreateCRMUserAsync(user, packageId, itemId, businessUnitOrgId, null);
 }
Пример #18
0
		protected void gvPopupAccounts_RowCommand(object sender, GridViewCommandEventArgs e)
		{
			if (e.CommandName == "SelectAccount")
			{
				string[] parts = e.CommandArgument.ToString().Split('|');
				OrganizationUser account = new OrganizationUser();
				account.AccountName = parts[0];
				account.DisplayName = parts[1];
			    account.PrimaryEmailAddress = parts[2];
			    account.AccountId = Utils.ParseInt(parts[3]);

				// set account
				BindSelectedAccount(account);

				// hide popup
				SelectAccountsModal.Hide();

				// update parent panel
				MainUpdatePanel.Update();
			}
		}
        public static List<OrganizationUser> SearchAccounts(int itemId,
            
            string filterColumn, string filterValue, string sortColumn, bool includeMailboxes )
        {
            #region Demo Mode
            if (IsDemoMode)
            {
                List<OrganizationUser> demoAccounts = new List<OrganizationUser>();


                OrganizationUser m1 = new OrganizationUser();
                    m1.AccountId = 1;
                    m1.AccountName = "john_fabrikam";
                    m1.AccountType = ExchangeAccountType.Mailbox;
                    m1.DisplayName = "John Smith";
                    m1.PrimaryEmailAddress = "*****@*****.**";
                    
                    if (includeMailboxes)                
                        demoAccounts.Add(m1);

                    OrganizationUser m2 = new OrganizationUser();
                    m2.AccountId = 2;
                    m2.AccountName = "jack_fabrikam";
                    m2.AccountType = ExchangeAccountType.User;
                    m2.DisplayName = "Jack Brown";
                    m2.PrimaryEmailAddress = "*****@*****.**";
                    demoAccounts.Add(m2);

                    OrganizationUser m3 = new OrganizationUser();
                    m3.AccountId = 3;
                    m3.AccountName = "marry_fabrikam";
                    m3.AccountType = ExchangeAccountType.Mailbox;
                    m3.DisplayName = "Marry Smith";
                    m3.PrimaryEmailAddress = "*****@*****.**";
                    
                    if (includeMailboxes)
                        demoAccounts.Add(m3);                  
                  

                return demoAccounts;
            }
            #endregion
            
            return ObjectUtils.CreateListFromDataReader<OrganizationUser>(
                DataProvider.SearchOrganizationAccounts(SecurityContext.User.UserId, itemId, 
                filterColumn, filterValue, sortColumn, includeMailboxes));
        }
Пример #20
0
 public UserResult CreateCRMUser(OrganizationUser user, string orgName, Guid organizationId, Guid baseUnitId)
 {
     return CrmProvider.CreateCRMUser(user, orgName, organizationId, baseUnitId);
 }
        public static OrganizationUsersPaged GetOrganizationUsersPaged(int itemId, string filterColumn, string filterValue, string sortColumn,
			int startRow, int maximumRows)
        {

            #region Demo Mode
            if (IsDemoMode)
            {                                
                OrganizationUsersPaged res = new OrganizationUsersPaged();
                List<OrganizationUser> demoAccounts = SearchAccounts(1, "", "", "", true);
                
                OrganizationUser r1 = new OrganizationUser();
                r1.AccountId = 20;
                r1.AccountName = "room1_fabrikam";
                r1.AccountType = ExchangeAccountType.Room;
                r1.DisplayName = "Meeting Room 1";
                r1.PrimaryEmailAddress = "*****@*****.**";
                demoAccounts.Add(r1);
                
                OrganizationUser e1 = new OrganizationUser();
                e1.AccountId = 21;
                e1.AccountName = "projector_fabrikam";
                e1.AccountType = ExchangeAccountType.Equipment;
                e1.DisplayName = "Projector 1";
                e1.PrimaryEmailAddress = "*****@*****.**";
                demoAccounts.Add(e1);
                res.PageUsers = demoAccounts.ToArray();
                res.RecordsCount = res.PageUsers.Length;
                return res;
            }
            #endregion
            
            string accountTypes = string.Format("{0}, {1}, {2}, {3}", ((int)ExchangeAccountType.User), ((int)ExchangeAccountType.Mailbox), ((int)ExchangeAccountType.Room), ((int)ExchangeAccountType.Equipment));
            
            
            DataSet ds =
                DataProvider.GetExchangeAccountsPaged(SecurityContext.User.UserId, itemId, accountTypes, filterColumn,
                                                      filterValue, sortColumn, startRow, maximumRows);
           
            OrganizationUsersPaged result = new OrganizationUsersPaged();
            result.RecordsCount = (int)ds.Tables[0].Rows[0][0];

            List<OrganizationUser> accounts = new List<OrganizationUser>();
            ObjectUtils.FillCollectionFromDataView(accounts, ds.Tables[1].DefaultView);
            result.PageUsers = accounts.ToArray();
            return result;
        }
 public ResultObject SaveRdsCollectionLocalAdmins(OrganizationUser[] users, int collectionId)
 {
     return RemoteDesktopServicesController.SaveRdsCollectionLocalAdmins(users, collectionId);
 }
Пример #23
0
 public void SetAccount(OrganizationUser account)
 {
     BindSelectedAccount(account);
 }
Пример #24
0
 private void BindSelectedAccount(OrganizationUser account)
 {
     if (account != null)
     {
         txtDisplayName.Text = account.DisplayName;
         ViewState["AccountName"] = account.AccountName;
         ViewState["DisplayName"] = account.DisplayName;
         ViewState["PrimaryEmailAddress"] = account.PrimaryEmailAddress;
         ViewState["AccountId"] = account.AccountId;
         ViewState["SAMAccountName"] = account.SamAccountName;
         ViewState["SubscriberNumber"] = account.SubscriberNumber;
     }
     else
     {
         txtDisplayName.Text = "";
         ViewState["AccountName"] = null;
         ViewState["DisplayName"] = null;
         ViewState["PrimaryEmailAddress"] = null;
         ViewState["AccountId"] = null;
         ViewState["SAMAccountName"] = null;
         ViewState["SubscriberNumber"] = null;
     }
 }
        private OrganizationUser GetUser(string organizationId, string path)
        {
            OrganizationUser retUser = new OrganizationUser();

            DirectoryEntry entry = ActiveDirectoryUtils.GetADObject(path);

            retUser.FirstName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.FirstName);
            retUser.LastName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.LastName);
            retUser.DisplayName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.DisplayName);
            retUser.Initials = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Initials);
            retUser.JobTitle = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.JobTitle);
            retUser.Company = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Company);
            retUser.Department = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Department);
            retUser.Office = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Office);
            retUser.BusinessPhone = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.BusinessPhone);
            retUser.Fax = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Fax);
            retUser.HomePhone = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.HomePhone);
            retUser.MobilePhone = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.MobilePhone);
            retUser.Pager = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Pager);
            retUser.WebPage = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.WebPage);
            retUser.Address = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Address);
            retUser.City = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.City);
            retUser.State = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.State);
            retUser.Zip = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Zip);
            retUser.Country = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Country);
            retUser.Notes = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Notes);
            retUser.ExternalEmail = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.ExternalEmail);
            retUser.Disabled = (bool)entry.InvokeGet(ADAttributes.AccountDisabled);
            retUser.Manager = GetManager(entry, ADAttributes.Manager);
            retUser.SamAccountName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.SAMAccountName);
            retUser.DomainUserName = GetDomainName(ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.SAMAccountName));
            retUser.DistinguishedName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.DistinguishedName);
            retUser.Locked = (bool)entry.InvokeGet(ADAttributes.AccountLocked);
            retUser.UserPrincipalName = (string)entry.InvokeGet(ADAttributes.UserPrincipalName);
            retUser.UserMustChangePassword = GetUserMustChangePassword(entry);

            return retUser;
        }
        public static void SetFolderOwaAccounts(int itemId, string folderName, OrganizationUser[] users)
        {
            try
            {
                var folderId = GetFolderId(itemId, folderName);

                DataProvider.DeleteAllEnterpriseFolderOwaUsers(itemId, folderId);

                foreach (var user in users)
                {
                    DataProvider.AddEnterpriseFolderOwaUser(itemId, folderId, user.AccountId);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        internal List<OrganizationUser> GetOrganizationUsersWithExpiredPasswordInternal(string organizationId, int daysBeforeExpiration)
        {
            var result = new List<OrganizationUser>();

            if (string.IsNullOrEmpty(organizationId))
            {
                return result;
            }

            Runspace runspace = null;

            try
            {
                runspace = OpenRunspace();

                var psoName = FormOrganizationPSOName(organizationId);

                var maxPasswordAgeSpan = GetMaxPasswordAge(runspace, psoName);

                var searchRoot = new DirectoryEntry(GetOrganizationPath(organizationId));

                var search = new DirectorySearcher(searchRoot)
                {
                    SearchScope = SearchScope.Subtree,
                    Filter = "(objectClass=user)"
                };

                search.PropertiesToLoad.Add("pwdLastSet");
                search.PropertiesToLoad.Add("sAMAccountName");

                SearchResultCollection searchResults = search.FindAll();

                foreach (SearchResult searchResult in searchResults)
                {
                    var pwdLastSetTicks = (long) searchResult.Properties["pwdLastSet"][0];

                    var pwdLastSetDate = DateTime.FromFileTimeUtc(pwdLastSetTicks);

                    var expirationDate = maxPasswordAgeSpan == TimeSpan.MaxValue ? DateTime.MaxValue : pwdLastSetDate.AddDays(maxPasswordAgeSpan.Days);

                    if (expirationDate.AddDays(-daysBeforeExpiration) < DateTime.Now)
                    {
                        var user = new OrganizationUser();

                        user.PasswordExpirationDateTime = expirationDate;
                        user.SamAccountName = (string) searchResult.Properties["sAMAccountName"][0];

                        result.Add(user);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                CloseRunspace(runspace);
            }

            return result;
        }
Пример #28
0
 public UserResult CreateCRMUser(OrganizationUser user, int packageId, int itemId, System.Guid businessUnitOrgId) {
     object[] results = this.Invoke("CreateCRMUser", new object[] {
                 user,
                 packageId,
                 itemId,
                 businessUnitOrgId});
     return ((UserResult)(results[0]));
 }
        protected List<OrganizationUser> GetGridViewUsers(SelectedState state)
        {
            List<OrganizationUser> users = new List<OrganizationUser>();
            for (int i = 0; i < gvUsers.Rows.Count; i++)
            {
                GridViewRow row = gvUsers.Rows[i];
                CheckBox chkSelect = (CheckBox)row.FindControl("chkSelect");
                if (chkSelect == null)
                    continue;

                OrganizationUser user = new OrganizationUser();
                user.AccountName = (string)gvUsers.DataKeys[i][0];
                user.DisplayName = ((Literal)row.FindControl("litAccount")).Text;
                user.SamAccountName = ((HiddenField)row.FindControl("hdnSamAccountName")).Value;

                if (state == SelectedState.All ||
                    (state == SelectedState.Selected && chkSelect.Checked) ||
                    (state == SelectedState.Unselected && !chkSelect.Checked))
                    users.Add(user);
            }

            return users;
        }
Пример #30
0
 /// <remarks/>
 public System.IAsyncResult BeginCreateCRMUser(OrganizationUser user, int packageId, int itemId, System.Guid businessUnitOrgId, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("CreateCRMUser", new object[] {
                 user,
                 packageId,
                 itemId,
                 businessUnitOrgId}, callback, asyncState);
 }
        public void SetUsers(OrganizationUser[] users)
		{
            BindAccounts(users, false);
		}
Пример #32
0
 public UserResult CreateCRMUser(OrganizationUser user, int packageId, int itemId, Guid businessUnitOrgId)
 {
     return CRMController.CreateCRMUser(user, packageId, itemId, businessUnitOrgId);
 }