asked on June 3, 2024

Hi! I designed this form to upload a photo and this photo I want to upload in AD to use in the all account M365 accounts as Outlook, MS teams and others:

In the research I found this code in C# to update the Phone number to use in a SDK script:

                string oldCellphone = GetTokenValue("RetrieveLaserficheFormsModificationsMod_account_modification_section_oldCellPhone").ToString();

                string newCellPhone = GetTokenValue("RetrieveLaserficheFormsModificationsMod_account_modification_section_newCellPhone").ToString();

                string strAuthUser = "user";
                string strAuthPass = "password";

                // Connect to LDAP
                string ldap = "LDAP://ldap.COM";

                DirectoryEntry directoryEntry = new DirectoryEntry(ldap, strAuthUser, strAuthPass, AuthenticationTypes.Secure);

                DirectorySearcher query = new DirectorySearcher(directoryEntry);

                if (!string.IsNullOrEmpty(newCellPhone))
                {
                    query.PropertiesToLoad.Add("mobile");
                    query.Filter = "(&(objectClass=user)(sAMAccountName=" +  employeeUsername + "))";
                    SearchResult result = query.FindOne();

                    if (result == null) return;

                    DirectoryEntry user = result.GetDirectoryEntry();
                    user.Properties["mobile"].Value = newCellPhone;
                    user.CommitChanges();
                    user.Close();
                }

Can I adapt this code to update the photo? How can I do that? Any assistance is appreciated it

0 0