private static SetOrganizationPL CreateSetOrganizationPLRequest(string organizationID) { SetOrganizationPL request = new SetOrganizationPL(); request.Item1 = organizationID; request.Item1ElementName = Item1ChoiceType7.ID; // set permissions request.permsManag = true; request.extensionManag = true; request.extensionManagSpecified = true; request.extFeatureManag = true; request.extFeatureManagSpecified = true; // set limits request.userMax = new unlimitedUInt() { unlimited = false, Value = 5 }; request.phoneExtMax = new unlimitedUInt() { unlimited = false, Value = 5 }; return(request); }
public static void SetOrganizationAccountPermissionsAndLimits(string accessToken, string organizationID) { if (string.IsNullOrEmpty(accessToken)) { Console.WriteLine("The access token cannot be null or empty!"); return; } if (string.IsNullOrEmpty(organizationID)) { Console.WriteLine("The organizationID 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 }; SetOrganizationPL request = CreateSetOrganizationPLRequest(organizationID); updateObject response = new updateObject(); OrganizationClient organizationClient = new OrganizationClient("OrganizationPort"); Console.WriteLine("Setting the Permissions and Limits for the Organization with the ID = {0}.", organizationID); try { organizationClient.SetOrganizationPL(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(); } }