public bool ChangeUserPassword(string login, string pwd, int requestor, int reqId, ref string err) { err = ""; bool logErr = false; bool fatal = false; try { if (String.IsNullOrEmpty(login)) { err = "ChangeUserPassword, Username is empty, OU=" + m_OU_Filter; int Event_id = 6021; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); return(false); } if (String.IsNullOrEmpty(pwd)) { err = "ChangeUserPassword, Password is empty, OU=" + m_OU_Filter; int Event_id = 6022; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); return(false); } if (reqId <= 0) { err = "ChangeUserPassword, RequestId must be greater than 0, reqId=" + reqId.ToString() + ", OU=" + m_OU_Filter; int Event_id = 6023; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); return(false); } if (requestor <= 0) // if there is no user id of the requestor is not given { requestor = 0; } User user = m_dataAccess.GetUserAccount(login, ref err); if (user == null) { err = "ChangeUserPassword, err: " + err; return(false); } if ((user.Firstname == string.Empty) || (user.Lastname == string.Empty)) { err = "ChangeUserPassword, username="******" missing First Name or Last Name in the database."; return(false); } //if (user.Password == string.Empty) //{ user.Password = pwd; //} ADUserDetail adUser = new ADUserDetail(user.Username, !user.Enabled, user.Firstname, user.Lastname, user.Email, user.Password); bool status = m_adHelper.ChangeUserPassword(adUser, ref err); if (status == false) { err += ", OU " + m_OU_Filter; int Event_id = 6024; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); } else { err = ""; } return(status); } catch (Exception ex) { //UpdateRequest(requestor, reqId, UserMgrCommandType.ChangePassword, false, ex.Message, ref err); err = "Failed to ChangeUserPassword the user account, username="******", OU " + m_OU_Filter + ", Exception:" + ex.Message; int Event_id = 6025; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); return(false); } finally { if (logErr) { int Event_id = 6026; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); } } }