示例#1
0
        public bool AddUsers(ServerDto serverDto, string tenant, GroupDto groupDto, IList <UserDto> users, Token token)
        {
            var principalName = Uri.EscapeDataString(groupDto.GroupName + "@" + groupDto.GroupDomain);

            tenant = Uri.EscapeDataString(tenant);
            var queryString = users.Select(x => "members=" + Uri.EscapeDataString(x.Name + "@" + x.Domain)).Aggregate((x, y) => string.Format("{0}&{1}", x, y));
            var url         = string.Format(_serviceConfigManager.GetMembersOfGroupEndPoint(), serverDto.Protocol, serverDto.ServerName, serverDto.Port, tenant, principalName, queryString, GroupMemberType.USER);

            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            var requestConfig = new RequestSettings
            {
                Method = HttpMethod.Put,
            };
            var headers  = ServiceHelper.AddHeaders(ServiceConstants.JsonContentType);
            var json     = "access_token=" + token.AccessToken + "&token_type=" + token.TokenType.ToString().ToLower();
            var response = _webRequestManager.GetResponse(url, requestConfig, headers, null, json);

            return(response != null);
        }