Ejemplo n.º 1
0
        private static int DiscoverADGroups(string group, SecurityGroupMapping map)
        {
            var users = LDAPHelper.SearchUsersByGroup(group);
            var count = 0;

            foreach (LDAPUser user in users)
            {
                if (CheckOffice(user.Office, map.Office))
                {
                    var prefix = "";

                    prefix = "i:0e.t|adfs|";

                    try
                    {
                        var employee = Employee.GetBy("AccountName", prefix + user.UPN);

                        if (!employee.Division.Contains(map.Abbreviation))
                        {
                            if (employee.Division == "N/A")
                            {
                                employee.Division = "";
                            }

                            if (employee.Division != "")
                            {
                                employee.Division += ", ";
                            }

                            employee.Division += map.Abbreviation;

                            employee.Save();
                            count++;
                        }
                    }
                    catch (Exception ex)
                    {
                        LDAPHelper.WriteException(ex, "SecurityGroupMapping.DiscoverADGroups : " + prefix + user.UPN);
                    }
                }
            }

            return(count);
        }