Пример #1
0
        public IEnumerable <DtGroup> GetAllGroups(out int sequence)
        {
            var offset  = 0;
            var hasMore = true;
            var result  = new List <DtGroup>();

            do
            {
                var jarray   = new JArray(client.GetDocument(WaadConfig.GroupApiFullName, offset, ReadLimit));
                var arr      = JObject.Parse(jarray[0].Value <string>());
                var contents = arr["contents"].Value <JArray>();
                sequence = arr["seq"].Value <int>();

                foreach (var row in contents)
                {
                    var datarow = new DtGroup().FromContentRow(row);
                    result.Add(datarow);
                }

                if (contents.Count < ReadLimit)
                {
                    hasMore = false;
                }
                else
                {
                    offset += ReadLimit;
                }
            } while (hasMore);

            return(result);
        }
Пример #2
0
        public void CreateGroup(DtGroup dtGroup)
        {
            if (directoryDataService.groups.Where(u => u.displayName == dtGroup.Name).FirstOrDefault() != null)
            {
                return;
            }

            var group = new AdGroup();

            group.displayName  = dtGroup.Name;
            group.mailNickname = dtGroup.MailNickName;
            //make all groups security enabled (i.e. not mailing lists)
            group.securityEnabled = true;
            group.mailEnabled     = false;
            directoryDataService.AddTogroups(group);
            directoryDataService.SaveChanges();
        }