Exemplo n.º 1
0
 public static void GetFFOMailUserList(DataRow inputRow, DataTable table, DataObjectStore store)
 {
     try
     {
         table.BeginLoadData();
         GetRecipientCmdlet getRecipientCmdlet = new GetRecipientCmdlet
         {
             Filter     = inputRow["SearchText"].ToString().ToRecipeintFilterString("((RecipientTypeDetails -eq 'UserMailbox') -or (RecipientTypeDetails -eq 'MailUser'))"),
             Properties = "Identity,DisplayName,PrimarySmtpAddress,RecipientTypeDetails"
         };
         getRecipientCmdlet.Authenticator  = PswsAuthenticator.Create();
         getRecipientCmdlet.HostServerName = AppConfigLoader.GetConfigStringValue("PswsHostName", null);
         foreach (Recipient recipient in getRecipientCmdlet.Run())
         {
             DataRow dataRow = table.NewRow();
             dataRow["Identity"]             = new Identity(recipient.Guid.ToString());
             dataRow["DisplayName"]          = recipient.DisplayName;
             dataRow["PrimarySmtpAddress"]   = recipient.PrimarySmtpAddress;
             dataRow["RecipientTypeDetails"] = FFOMailUser.GenerateUserTypeText(Enum.Parse(typeof(RecipientTypeDetails), recipient.RecipientTypeDetails, true));
             table.Rows.Add(dataRow);
         }
     }
     finally
     {
         table.EndLoadData();
     }
 }
Exemplo n.º 2
0
        public static void NewFFOMailUser(DataRow inputRow, DataTable table, DataObjectStore store)
        {
            NewMailUserCmdlet newMailUserCmdlet = new NewMailUserCmdlet();

            newMailUserCmdlet.Authenticator  = PswsAuthenticator.Create();
            newMailUserCmdlet.HostServerName = AppConfigLoader.GetConfigStringValue("PswsHostName", null);
            if (!string.IsNullOrEmpty(inputRow["FirstName"].ToString()))
            {
                newMailUserCmdlet.FirstName = inputRow["FirstName"].ToString();
            }
            if (!string.IsNullOrEmpty(inputRow["Initials"].ToString()))
            {
                newMailUserCmdlet.Initials = inputRow["Initials"].ToString();
            }
            if (!string.IsNullOrEmpty(inputRow["LastName"].ToString()))
            {
                newMailUserCmdlet.LastName = inputRow["LastName"].ToString();
            }
            if (!string.IsNullOrEmpty(inputRow["ExternalEmailAddress"].ToString()))
            {
                newMailUserCmdlet.ExternalEmailAddress = inputRow["ExternalEmailAddress"].ToString();
            }
            newMailUserCmdlet.Alias                     = inputRow["Alias"].ToString();
            newMailUserCmdlet.DisplayName               = inputRow["MailUserDisplayName"].ToString();
            newMailUserCmdlet.Name                      = inputRow["MailUserDisplayName"].ToString();
            newMailUserCmdlet.Password                  = inputRow["PlainPassword"].ToString();
            newMailUserCmdlet.PrimarySmtpAddress        = inputRow["PrimarySmtpAddress"].ToString();
            newMailUserCmdlet.MicrosoftOnlineServicesID = inputRow["MicrosoftOnlineServicesID"].ToString();
            newMailUserCmdlet.Run();
            if (!string.IsNullOrEmpty(newMailUserCmdlet.Error))
            {
                throw new Exception(newMailUserCmdlet.Error);
            }
        }
Exemplo n.º 3
0
        public static void GetFFOMailUserSDO(DataRow inputRow, DataTable table, DataObjectStore store)
        {
            GetRecipientCmdlet getRecipientCmdlet = new GetRecipientCmdlet
            {
                Identity = ((Identity)inputRow["Identity"]).RawIdentity
            };

            getRecipientCmdlet.Authenticator  = PswsAuthenticator.Create();
            getRecipientCmdlet.HostServerName = AppConfigLoader.GetConfigStringValue("PswsHostName", null);
            Recipient[] array = getRecipientCmdlet.Run();
            if (array == null || array.Length == 0)
            {
                throw new ExArgumentOutOfRangeException();
            }
            Recipient recipient = array.First <Recipient>();
            DataRow   dataRow   = table.Rows[0];

            dataRow["Identity"]           = new Identity(recipient.Guid.ToString());
            dataRow["DisplayName"]        = recipient.DisplayName;
            dataRow["Alias"]              = recipient.Alias;
            dataRow["PrimarySmtpAddress"] = recipient.PrimarySmtpAddress;
            dataRow["Name"]       = recipient.Name;
            dataRow["FirstName"]  = recipient.FirstName;
            dataRow["LastName"]   = recipient.LastName;
            dataRow["Title"]      = recipient.Title;
            dataRow["Department"] = recipient.Department;
            dataRow["Office"]     = recipient.Office;
            dataRow["Phone"]      = recipient.Phone;
        }
        public static void GetFFOSDOItem(DataRow inputRow, DataTable table, DataObjectStore store)
        {
            GetDistributionGroupCmdlet getDistributionGroupCmdlet = new GetDistributionGroupCmdlet
            {
                Identity = ((Identity)inputRow["Identity"]).RawIdentity
            };

            getDistributionGroupCmdlet.Authenticator  = PswsAuthenticator.Create();
            getDistributionGroupCmdlet.HostServerName = AppConfigLoader.GetConfigStringValue("PswsHostName", null);
            DistributionGroup[] array = getDistributionGroupCmdlet.Run();
            if (array == null || array.Length == 0)
            {
                throw new ExArgumentOutOfRangeException();
            }
            DistributionGroup distributionGroup = array.First <DistributionGroup>();
            DataRow           dataRow           = table.Rows[0];

            dataRow["Identity"]             = new Identity(distributionGroup.Guid.ToString());
            dataRow["DisplayName"]          = distributionGroup.DisplayName;
            dataRow["PrimarySmtpAddress"]   = distributionGroup.PrimarySmtpAddress;
            dataRow["RecipientTypeDetails"] = DistributionGroupHelper.GenerateGroupTypeText(Enum.Parse(typeof(RecipientTypeDetails), distributionGroup.RecipientTypeDetails, true));
            dataRow["GroupType"]            = DistributionGroupHelper.GenerateGroupTypeText(Enum.Parse(typeof(RecipientTypeDetails), distributionGroup.RecipientTypeDetails, true));
            dataRow["Notes"] = distributionGroup.Notes;
            if (distributionGroup.ManagedBy == null || distributionGroup.ManagedBy.Length == 0)
            {
                dataRow["DisplayedManagedBy"] = null;
            }
            else
            {
                string[] value = (from o in distributionGroup.ManagedBy
                                  select o.Name).ToArray <string>();
                dataRow["DisplayedManagedBy"] = value;
            }
            GetGroupCmdlet getGroupCmdlet = new GetGroupCmdlet
            {
                Identity = ((Identity)inputRow["Identity"]).RawIdentity
            };

            getGroupCmdlet.Authenticator  = PswsAuthenticator.Create();
            getGroupCmdlet.HostServerName = AppConfigLoader.GetConfigStringValue("PswsHostName", null);
            Group[] array2 = getGroupCmdlet.Run();
            if (array2 == null || array2.Length == 0)
            {
                throw new ExArgumentOutOfRangeException();
            }
            Group group = array2.First <Group>();

            if (group.Members == null || group.Members.Length == 0)
            {
                dataRow["MemberCount"] = 0;
            }
            else
            {
                dataRow["MemberCount"] = group.Members.Length;
            }
            dataRow["Notes"] = group.Notes;
        }
Exemplo n.º 5
0
        public static void GetFFOMailUser(DataRow inputRow, DataTable table, DataObjectStore store)
        {
            GetRecipientCmdlet getRecipientCmdlet = new GetRecipientCmdlet
            {
                Identity = ((Identity)inputRow["Identity"]).RawIdentity
            };

            getRecipientCmdlet.Authenticator  = PswsAuthenticator.Create();
            getRecipientCmdlet.HostServerName = AppConfigLoader.GetConfigStringValue("PswsHostName", null);
            Recipient[] array = getRecipientCmdlet.Run();
            if (array == null || array.Length == 0)
            {
                throw new ExArgumentOutOfRangeException();
            }
            Recipient recipient = array.First <Recipient>();
            DataRow   dataRow   = table.Rows[0];

            dataRow["Identity"]           = new Identity(recipient.Guid.ToString());
            dataRow["FirstName"]          = recipient.FirstName;
            dataRow["LastName"]           = recipient.LastName;
            dataRow["DisplayName"]        = recipient.DisplayName;
            dataRow["WindowsLiveID"]      = recipient.WindowsLiveID;
            dataRow["City"]               = recipient.City;
            dataRow["StateOrProvince"]    = recipient.StateOrProvince;
            dataRow["PostalCode"]         = recipient.PostalCode;
            dataRow["CountryOrRegion"]    = recipient.CountryOrRegion.Name;
            dataRow["Phone"]              = recipient.Phone;
            dataRow["Office"]             = recipient.Office;
            dataRow["Notes"]              = recipient.Notes;
            dataRow["Title"]              = recipient.Title;
            dataRow["Department"]         = recipient.Department;
            dataRow["Company"]            = recipient.Company;
            dataRow["Alias"]              = recipient.Alias;
            dataRow["PrimarySmtpAddress"] = recipient.PrimarySmtpAddress;
            dataRow["Name"]               = recipient.Name;
            GetUserCmdlet getUserCmdlet = new GetUserCmdlet
            {
                Identity = ((Identity)inputRow["Identity"]).RawIdentity
            };

            getUserCmdlet.Authenticator  = PswsAuthenticator.Create();
            getUserCmdlet.HostServerName = AppConfigLoader.GetConfigStringValue("PswsHostName", null);
            User[] array2 = getUserCmdlet.Run();
            if (array2 == null || array2.Length == 0)
            {
                throw new ExArgumentOutOfRangeException();
            }
            User user = array2.First <User>();

            dataRow["Initials"]      = user.Initials;
            dataRow["StreetAddress"] = user.StreetAddress;
            dataRow["MobilePhone"]   = user.MobilePhone;
            dataRow["Fax"]           = user.Fax;
            dataRow["HomePhone"]     = user.HomePhone;
            dataRow["WebPage"]       = user.WebPage;
        }
Exemplo n.º 6
0
        public static void RemoveFFOMailUser(DataRow inputRow, DataTable table, DataObjectStore store)
        {
            RemoveMailUserCmdlet removeMailUserCmdlet = new RemoveMailUserCmdlet();

            removeMailUserCmdlet.Authenticator  = PswsAuthenticator.Create();
            removeMailUserCmdlet.HostServerName = AppConfigLoader.GetConfigStringValue("PswsHostName", null);
            removeMailUserCmdlet.Identity       = ((Identity)inputRow["Identity"]).RawIdentity;
            removeMailUserCmdlet.Run();
            if (!string.IsNullOrEmpty(removeMailUserCmdlet.Error))
            {
                throw new Exception(removeMailUserCmdlet.Error);
            }
        }
        public static void NewFFOGroup(DataRow inputRow, DataTable table, DataObjectStore store)
        {
            NewDistributionGroupCmdlet newDistributionGroupCmdlet = new NewDistributionGroupCmdlet();

            newDistributionGroupCmdlet.Authenticator      = PswsAuthenticator.Create();
            newDistributionGroupCmdlet.HostServerName     = AppConfigLoader.GetConfigStringValue("PswsHostName", null);
            newDistributionGroupCmdlet.Name               = inputRow["Name"].ToString();
            newDistributionGroupCmdlet.DisplayName        = inputRow["Name"].ToString();
            newDistributionGroupCmdlet.Alias              = inputRow["Alias"].ToString();
            newDistributionGroupCmdlet.PrimarySmtpAddress = inputRow["PrimarySmtpAddress"].ToString();
            newDistributionGroupCmdlet.Notes              = inputRow["Notes"].ToString();
            string[] managedBy = (from o in (object[])inputRow["ManagedBy"]
                                  select((Identity)o).DisplayName).ToArray <string>();
            newDistributionGroupCmdlet.ManagedBy = managedBy;
            string[] members = (from o in (object[])inputRow["Members"]
                                select((Identity)o).DisplayName).ToArray <string>();
            newDistributionGroupCmdlet.Members = members;
            newDistributionGroupCmdlet.Type    = inputRow["GroupType"].ToString();
            newDistributionGroupCmdlet.Run();
            if (!string.IsNullOrEmpty(newDistributionGroupCmdlet.Error))
            {
                throw new Exception(newDistributionGroupCmdlet.Error);
            }
        }
Exemplo n.º 8
0
        public static void SetFFOMailUser(DataRow inputRow, DataTable table, DataObjectStore store)
        {
            SetUserCmdlet setUserCmdlet = new SetUserCmdlet();

            setUserCmdlet.Authenticator  = PswsAuthenticator.Create();
            setUserCmdlet.HostServerName = AppConfigLoader.GetConfigStringValue("PswsHostName", null);
            setUserCmdlet.Identity       = ((Identity)inputRow["Identity"]).RawIdentity;
            if (!DBNull.Value.Equals(inputRow["DisplayName"]))
            {
                setUserCmdlet.DisplayName = inputRow["DisplayName"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["FirstName"]))
            {
                setUserCmdlet.FirstName = inputRow["FirstName"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["LastName"]))
            {
                setUserCmdlet.LastName = inputRow["LastName"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["Initials"]))
            {
                setUserCmdlet.Initials = inputRow["Initials"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["City"]))
            {
                setUserCmdlet.City = inputRow["City"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["Office"]))
            {
                setUserCmdlet.Office = inputRow["Office"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["StateOrProvince"]))
            {
                setUserCmdlet.StateOrProvince = inputRow["StateOrProvince"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["PostalCode"]))
            {
                setUserCmdlet.PostalCode = inputRow["PostalCode"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["CountryOrRegion"]))
            {
                setUserCmdlet.CountryOrRegion = inputRow["CountryOrRegion"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["Phone"]))
            {
                setUserCmdlet.Phone = inputRow["Phone"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["Notes"]))
            {
                setUserCmdlet.Notes = inputRow["Notes"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["Title"]))
            {
                setUserCmdlet.Title = inputRow["Title"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["Department"]))
            {
                setUserCmdlet.Department = inputRow["Department"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["Company"]))
            {
                setUserCmdlet.Company = inputRow["Company"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["StreetAddress"]))
            {
                setUserCmdlet.StreetAddress = inputRow["StreetAddress"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["MobilePhone"]))
            {
                setUserCmdlet.MobilePhone = inputRow["MobilePhone"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["Fax"]))
            {
                setUserCmdlet.Fax = inputRow["Fax"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["HomePhone"]))
            {
                setUserCmdlet.HomePhone = inputRow["HomePhone"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["WebPage"]))
            {
                setUserCmdlet.WebPage = inputRow["WebPage"].ToString();
            }
            setUserCmdlet.Run();
            if (!string.IsNullOrEmpty(setUserCmdlet.Error))
            {
                throw new Exception(setUserCmdlet.Error);
            }
        }
        public static void GetFFOItem(DataRow inputRow, DataTable table, DataObjectStore store)
        {
            GetDistributionGroupCmdlet getDistributionGroupCmdlet = new GetDistributionGroupCmdlet
            {
                Identity = ((Identity)inputRow["Identity"]).RawIdentity
            };

            getDistributionGroupCmdlet.Authenticator  = PswsAuthenticator.Create();
            getDistributionGroupCmdlet.HostServerName = AppConfigLoader.GetConfigStringValue("PswsHostName", null);
            DistributionGroup[] array = getDistributionGroupCmdlet.Run();
            if (array == null || array.Length == 0)
            {
                throw new ExArgumentOutOfRangeException();
            }
            DistributionGroup distributionGroup = array.First <DistributionGroup>();
            DataRow           dataRow           = table.Rows[0];

            dataRow["Identity"]           = new Identity(distributionGroup.Guid.ToString());
            dataRow["DisplayName"]        = distributionGroup.DisplayName;
            dataRow["Alias"]              = distributionGroup.Alias;
            dataRow["PrimarySmtpAddress"] = distributionGroup.PrimarySmtpAddress;
            dataRow["Notes"]              = distributionGroup.Notes;
            if (distributionGroup.ManagedBy == null || distributionGroup.ManagedBy.Length == 0)
            {
                dataRow["ManagedBy"] = null;
            }
            else
            {
                dataRow["ManagedBy"] = (from g in distributionGroup.ManagedBy
                                        select new JsonDictionary <object>(new Dictionary <string, object>
                {
                    {
                        "__type",
                        "JsonDictionaryOfanyType:#Microsoft.Exchange.Management.ControlPanel"
                    },
                    {
                        "Identity",
                        new Identity(g.Name, g.Name)
                    },
                    {
                        "DisplayName",
                        g.Name
                    },
                    {
                        "Name",
                        g.Name
                    }
                })).ToArray <JsonDictionary <object> >();
            }
            dataRow["EmailAddresses"] = distributionGroup.EmailAddresses;
            GetGroupCmdlet getGroupCmdlet = new GetGroupCmdlet
            {
                Identity = ((Identity)inputRow["Identity"]).RawIdentity
            };

            getGroupCmdlet.Authenticator  = PswsAuthenticator.Create();
            getGroupCmdlet.HostServerName = AppConfigLoader.GetConfigStringValue("PswsHostName", null);
            Group[] array2 = getGroupCmdlet.Run();
            if (array2 == null || array2.Length == 0)
            {
                throw new ExArgumentOutOfRangeException();
            }
            Group group = array2.First <Group>();

            if (group.Members == null || group.Members.Length == 0)
            {
                dataRow["Members"] = null;
            }
            else
            {
                dataRow["Members"] = (from g in @group.Members
                                      select new JsonDictionary <object>(new Dictionary <string, object>
                {
                    {
                        "__type",
                        "JsonDictionaryOfanyType:#Microsoft.Exchange.Management.ControlPanel"
                    },
                    {
                        "Identity",
                        new Identity(g)
                    },
                    {
                        "DisplayName",
                        g
                    },
                    {
                        "Name",
                        g
                    }
                })).ToArray <JsonDictionary <object> >();
            }
            dataRow["Notes"] = group.Notes;
        }
        public static void SetFFOGroup(DataRow inputRow, DataTable table, DataObjectStore store)
        {
            SetDistributionGroupCmdlet setDistributionGroupCmdlet = new SetDistributionGroupCmdlet();

            setDistributionGroupCmdlet.Authenticator  = PswsAuthenticator.Create();
            setDistributionGroupCmdlet.HostServerName = AppConfigLoader.GetConfigStringValue("PswsHostName", null);
            setDistributionGroupCmdlet.Identity       = ((Identity)inputRow["Identity"]).RawIdentity;
            if (!DBNull.Value.Equals(inputRow["DisplayName"]))
            {
                setDistributionGroupCmdlet.DisplayName = inputRow["DisplayName"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["Alias"]))
            {
                setDistributionGroupCmdlet.Alias = inputRow["Alias"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["PrimarySmtpAddress"]))
            {
                setDistributionGroupCmdlet.PrimarySmtpAddress = inputRow["PrimarySmtpAddress"].ToString();
            }
            if (!DBNull.Value.Equals(inputRow["ManagedBy"]))
            {
                string[] managedBy = (from o in (object[])inputRow["ManagedBy"]
                                      select((Identity)o).DisplayName).ToArray <string>();
                setDistributionGroupCmdlet.ManagedBy = managedBy;
            }
            setDistributionGroupCmdlet.Run();
            if (!string.IsNullOrEmpty(setDistributionGroupCmdlet.Error))
            {
                throw new Exception(setDistributionGroupCmdlet.Error);
            }
            if (!DBNull.Value.Equals(inputRow["MembersRemoved"]) || !DBNull.Value.Equals(inputRow["MembersAdded"]))
            {
                string[] members = (from o in (object[])inputRow["Members"]
                                    select((Identity)o).DisplayName).ToArray <string>();
                UpdateDistributionGroupMemberCmdlet updateDistributionGroupMemberCmdlet = new UpdateDistributionGroupMemberCmdlet();
                updateDistributionGroupMemberCmdlet.Authenticator  = PswsAuthenticator.Create();
                updateDistributionGroupMemberCmdlet.HostServerName = AppConfigLoader.GetConfigStringValue("PswsHostName", null);
                updateDistributionGroupMemberCmdlet.Identity       = ((Identity)inputRow["Identity"]).RawIdentity;
                updateDistributionGroupMemberCmdlet.Members        = members;
                updateDistributionGroupMemberCmdlet.Run();
                if (!string.IsNullOrEmpty(updateDistributionGroupMemberCmdlet.Error))
                {
                    throw new Exception(updateDistributionGroupMemberCmdlet.Error);
                }
            }
            if (!DBNull.Value.Equals(inputRow["Notes"]))
            {
                SetGroupCmdlet setGroupCmdlet = new SetGroupCmdlet();
                setGroupCmdlet.Authenticator  = PswsAuthenticator.Create();
                setGroupCmdlet.HostServerName = AppConfigLoader.GetConfigStringValue("PswsHostName", null);
                setGroupCmdlet.Identity       = ((Identity)inputRow["Identity"]).RawIdentity;
                setGroupCmdlet.Notes          = inputRow["Notes"].ToString();
                if (!DBNull.Value.Equals(inputRow["ManagedBy"]))
                {
                    string[] managedBy2 = (from o in (object[])inputRow["ManagedBy"]
                                           select((Identity)o).DisplayName).ToArray <string>();
                    setGroupCmdlet.ManagedBy = managedBy2;
                }
                setGroupCmdlet.Run();
                if (!string.IsNullOrEmpty(setGroupCmdlet.Error))
                {
                    throw new Exception(setGroupCmdlet.Error);
                }
            }
        }