Код: Выделить всё
public static void AddPictureToUser(string strFileName)
{
// Open file
System.IO.FileStream inFile = new System.IO.FileStream(strFileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
// Retreive Data into a byte array variable
byte[] binaryData = new byte[inFile.Length];
inFile.Close();
string ldap = "LDAP://COMPANY.COM:389";
string userAuthToMakeChanges = "user";
string passwordUserAuthToMakeChanges = "password";
string employeeUsername = "usernameToFind";
System.DirectoryServices.DirectoryEntry directoryEntry = new System.DirectoryServices.DirectoryEntry(ldap, userAuthToMakeChanges, passwordUserAuthToMakeChanges, AuthenticationTypes.Secure);
DirectorySearcher query = new DirectorySearcher(directoryEntry);
query.PropertiesToLoad.Add("thumbnailPhoto");
query.Filter = "(&(objectClass=user)(sAMAccountName=" + employeeUsername + "))";
SearchResult result = query.FindOne();
System.DirectoryServices.DirectoryEntry user = result.GetDirectoryEntry();
// Clear existing picture if exists
user.Properties["thumbnailPhoto"].Clear();
// Update attribute with binary data from file
user.Properties["thumbnailPhoto"].Add(binaryData);
user.CommitChanges();
}
Нет больше информации < /p>
Я не думаю, что проблема связана с доступом, потому что я могу изменить данные сотрудника с этим инструментом. https://www.codetwo.com/freeware/active ... /?sts=1327
Что, по вашему мнению, происходит?
Подробнее здесь: https://stackoverflow.com/questions/786 ... gh-c-sharp
Мобильная версия