/// <summary> /// Get Users. Returns dictionary of User Ids and corresponding User names /// </summary> public virtual Dictionary <int, string> GetUsers() { // create return object Dictionary <int, string> results = new Dictionary <int, string>(); // set the default maximum users int maxUsers = 15; GetUserAccessResponse userAccess = GetUserAccess(defaultUser, defaultChannel); if (userAccess.CompletionCode == 0) { // get maximum user Ids allowed on BMC maxUsers = Convert.ToInt32(userAccess.MaxUsers); } else { // Surpress IpmiResponseException. Most bmc types will not throw exceptions // HP iLO firmware 1.87, which throws exceptions as the does not implement userId's in accordance // with the ipmi specification. } // loop through all User Id slots on BMC // start for loop at defaultUser(1) // Ipmi userId 1 is always null, except on HP firmware 1.87 for (int i = defaultUser; i <= maxUsers; i++) { byte userByte = Convert.ToByte(i); // Get User Name assigned to User Id GetUserNameResponse UserNameResponse = (GetUserNameResponse)this.IpmiSendReceive( new GetUserNameRequest(userByte), typeof(GetUserNameResponse)); if (UserNameResponse != null) { if (UserNameResponse.CompletionCode == 0) { string userNameStr = System.Text.ASCIIEncoding.ASCII.GetString(UserNameResponse.UserName).TrimEnd('\0'); if (!results.ContainsKey(i)) { results.Add(i, userNameStr); } } } else { // Surpress IpmiResponseException. Most bmc types will not throw exceptions // HP MACH1+ throw exceptions as the does not implement userId's in accordance // with the ipmi specification } UserNameResponse = null; } return(results); }
/// <summary> /// Get Users. Returns dictionary of User Ids and corresponding User names /// </summary> public virtual Dictionary <int, string> GetUsers() { // create return object Dictionary <int, string> results = new Dictionary <int, string>(); // maximum users int maxUsers = 0; GetUserAccessResponse userAccess = GetUserAccess(defaultUser, defaultChannel); if (userAccess.CompletionCode == 0) { // get maximum user Ids allowed on BMC maxUsers = Convert.ToInt32(userAccess.MaxUsers); } // loop through all User Id slots on BMC // start for loop at defaultUser(1) for (int i = defaultUser; i <= maxUsers; i++) { byte userByte = Convert.ToByte(i); // Get User Name assigned to User Id GetUserNameResponse UserNameResponse = (GetUserNameResponse)this.IpmiSendReceive( new GetUserNameRequest(userByte), typeof(GetUserNameResponse)); if (UserNameResponse != null) { if (UserNameResponse.CompletionCode == 0) { string userNameStr = System.Text.ASCIIEncoding.ASCII.GetString(UserNameResponse.UserName).TrimEnd('\0'); if (!results.ContainsKey(i)) { results.Add(i, userNameStr); } } } UserNameResponse = null; } return(results); }
/// <summary> /// Get User Name /// </summary> /// <param name="userId">User Id.</param> public virtual UserName GetUserName(int userId) { byte userByte = Convert.ToByte(userId); GetUserNameResponse response = (GetUserNameResponse)this.IpmiSendReceive( new GetUserNameRequest(userByte), typeof(GetUserNameResponse)); UserName responseObj = new UserName(response.CompletionCode); if (response.CompletionCode == 0) { responseObj.SetParamaters(response.UserName); } return(responseObj); }