Beispiel #1
0
        /// <summary>
        /// Extract contact information from an Active Directory entry
        /// </summary>
        /// <param name="resultProperties"> </param>
        /// <returns> a standard contact entity </returns>
        private static StdContact ConvertToContact(PropertyCollection resultProperties)
        {
            var result = new StdContact
            {
                Id = Guid.NewGuid(),
                InternalSyncData =
                    new SyncData
                {
                    DateOfCreation   = resultProperties.GetPropDate("whencreated"),
                    DateOfLastChange = resultProperties.GetPropDate("whenchanged"),
                },
                BusinessAddressPrimary =
                    new AddressDetail
                {
                    CountryName = resultProperties.GetPropString("co"),
                    StateName   = resultProperties.GetPropString("st"),
                    PostalCode  = resultProperties.GetPropString("postalcode"),
                    CityName    = resultProperties.GetPropString("l"),
                    StreetName  = resultProperties.GetPropString("streetaddress"),
                    Phone       = new PhoneNumber(resultProperties.GetPropString("telephonenumber")),
                    Room        = resultProperties.GetPropString("physicaldeliveryofficename", "roomnumber"),
                },
                BusinessPhoneMobile    = new PhoneNumber(resultProperties.GetPropString("mobile")),
                BusinessPosition       = resultProperties.GetPropString("title"),
                BusinessCompanyName    = resultProperties.GetPropString("company"),
                BusinessDepartment     = resultProperties.GetPropString("department"),
                BusinessEmailPrimary   = resultProperties.GetPropString("mail"),
                PersonalAddressPrimary =
                    new AddressDetail
                {
                    Phone = new PhoneNumber(resultProperties.GetPropString("homephone")),
                },
                Name =
                    new PersonName
                {
                    FirstName = resultProperties.GetPropString("givenname"),
                    LastName  = resultProperties.GetPropString("sn"),
                },
                PersonGender       = SyncTools.GenderByText(resultProperties.GetPropString("personaltitle")),
                AdditionalTextData = resultProperties.GetPropString("info"),
                ImageEntries       = new List <ImageEntry>
                {
                    new ImageEntry
                    {
                        ImageData = resultProperties.GetPropBytes("thumbnailPhoto"),
                        ImageName = "ActiveDirectory",
                    }
                }
            };

            result.ExternalIdentifier.SetProfileId(ProfileIdentifierType.ActiveDirectoryId, resultProperties.GetPropString("CN"));
            result.NormalizeContent();

            return(result);
        }