/// <summary> /// Returns an AirWatchUser class populated with the returned user if found. Returns null if not found /// </summary> /// <param name="searchString">AirWatch Username or Email address of user to search</param> /// <param name="searchType"></param> /// <returns>An AirWatchUser or null</returns> public AirWatchUser SearchForUser(string searchString, UserSearchType searchType) { string apiEndpoint = string.Empty; if (searchType == UserSearchType.Username) { apiEndpoint = "/API/v1/system/users/search?username="******"/API/v1/system/users/search?email=" + searchString; } AirWatchUser userToReturn = new AirWatchUser(); IRestResponse response = restHandler.RestGetEndpointBasicAuth(apiEndpoint, userName, password, headers); AirWatchUsers awUser = new AirWatchUsers(); if (response.StatusDescription == "OK") { AirWatchUsers usersReturned = new AirWatchUsers(); JsonConvert.PopulateObject(response.Content, usersReturned); userToReturn = usersReturned.Users[0]; } else { userToReturn = null; } return userToReturn; }
public void TestCreateBasicAirWatchUser() { // Add basic user /* AirWatchUser newUser = new AirWatchUser(); newUser.Email = "*****@*****.**"; newUser.FirstName = "Vincent"; newUser.LastName = "Curry"; newUser.LocationGroupID = locationGroupID; newUser.MessageType = "Email"; newUser.Password = "******"; newUser.SecurityType = 2; newUser.Status = true; newUser.UserName = "******"; newUser.EmailUserName = "******"; */ // Add Directory user AirWatchUser newUser = new AirWatchUser(); newUser.UserName = "******"; newUser.Status = true; newUser.SecurityType = 1; string userJSON = JsonConvert.SerializeObject(newUser); string awSiteURL = awServer; RestHandler restHandler = new RestHandler(awSiteURL); IRestResponse returnCode = restHandler.RestPostEndpointBasicAuth("/API/v1/system/users/adduser", userName, password, headers, userJSON); if (returnCode.StatusDescription == "OK") { JObject returnedContent = JObject.Parse(returnCode.Content); string createdUserId = (string)returnedContent["Value"]; using (StreamWriter sw = new StreamWriter(createUserFile)) { sw.WriteLine(Convert.ToString(createdUserId)); } } Assert.AreEqual("OK", returnCode.StatusDescription); }
private int createUserAllOverLoads(string userName, string password, string emailAddress, string firstName, string lastName, string roleName) { AirWatchUser userToCreate = new AirWatchUser(); userToCreate.UserName = userName; userToCreate.Password = password; userToCreate.Email = emailAddress; userToCreate.FirstName = firstName; userToCreate.LastName = lastName; if (roleName != null) userToCreate.Role = roleName; return 0; }