private static SetUserPL CreateSetUserPLRequest(string userID) { SetUserPL request = new SetUserPL(); request.Item1 = userID; request.Item1ElementName = Item1ChoiceType12.ID; // set permissions request.extensionManag = true; request.extensionManagSpecified = true; request.extFeatureManag = true; request.extFeatureManagSpecified = true; // set limits request.phoneExtMax = new unlimitedUInt() { unlimited = false, Value = 5 }; return(request); }
public static void SetUserAccountPermissionsAndLimits(string accessToken, string userID) { if (string.IsNullOrEmpty(accessToken)) { Console.WriteLine("The access token cannot be null or empty!"); return; } if (string.IsNullOrEmpty(userID)) { Console.WriteLine("The userID parameter cannot be null or empty!"); return; } ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); }; ServicePointManager.Expect100Continue = false; userCredentials credentials = new userCredentials() { accessToken = accessToken }; SetUserPL request = CreateSetUserPLRequest(userID); updateObject response = new updateObject(); UserClient userClient = new UserClient("UserPort"); Console.WriteLine("Set the Permissions and Limits for the User with the ID = {0}.", userID); try { userClient.SetUserPL(credentials, request, out response); } catch (Exception e) { //exception found, so we check the stack trc String trace = e.StackTrace; //write the stack trace to the console Console.WriteLine("{0} Exception caught.", e); //wait for the user to press a key before closing the console Console.Read(); } finally { Console.WriteLine("The operation response:"); foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(response)) { string name = descriptor.Name; object value = descriptor.GetValue(response); Console.WriteLine("\t{0}={1}", name, value); } Console.WriteLine(); } }