예제 #1
0
        /// <summary>
        /// ######### ########## ############# LDAP.
        /// </summary>
        private void InsertLDAPUsers(List <LdapUser> ldapElements, Guid ldapGroupId)
        {
            var activeLdapElements = ldapElements.Where(item => item.IsActive).ToList();

            foreach (var ldapElement in activeLdapElements)
            {
                var entity     = new LDAPElement(CurrentUserConnection);
                var conditions = new Dictionary <string, object> {
                    { "LDAPEntryId", ldapElement.Id },
                    { "Type", (int)Core.DB.SysAdminUnitType.User }
                };
                lock (_lockObject) {
                    if (!entity.FetchFromDB(conditions))
                    {
                        entity.SetDefColumnValues();
                        entity.SetColumnValue("Type", (int)Core.DB.SysAdminUnitType.User);
                        entity.SetColumnValue("IsActive", true);
                        entity.SetColumnValue("LDAPEntryId", ldapElement.Id);
                    }
                    entity.SetColumnValue("Name", ldapElement.Name);
                    entity.SetColumnValue("FullName", ldapElement.FullName);
                    entity.SetColumnValue("Company", ldapElement.Company);
                    entity.SetColumnValue("Email", ldapElement.Email);
                    entity.SetColumnValue("Phone", ldapElement.Phone);
                    entity.SetColumnValue("JobTitle", ldapElement.JobTitle);
                    entity.SetColumnValue("LDAPEntryDN", ldapElement.Dn);
                    entity.Save();
                    Guid ldapUserId      = entity.PrimaryColumnValue;
                    var  esqLdapLElement = new EntitySchemaQuery(CurrentUserConnection.EntitySchemaManager, "LDAPUserInLDAPGroup");
                    esqLdapLElement.AddColumn("LDAPUser");
                    esqLdapLElement.Filters.Add(esqLdapLElement.CreateFilterWithParameters(
                                                    FilterComparisonType.Equal, "LDAPUser", ldapUserId));
                    esqLdapLElement.Filters.Add(esqLdapLElement.CreateFilterWithParameters(
                                                    FilterComparisonType.Equal, "LDAPGroup", ldapGroupId));
                    var collection = esqLdapLElement.GetEntityCollection(CurrentUserConnection);
                    if (collection.Count == 0)
                    {
                        var userInLDAPGroupEntity = new Terrasoft.Configuration.LDAPUserInLDAPGroup(CurrentUserConnection);
                        userInLDAPGroupEntity.SetDefColumnValues();
                        userInLDAPGroupEntity.SetColumnValue("LDAPUserId", ldapUserId);
                        userInLDAPGroupEntity.SetColumnValue("LDAPGroupId", ldapGroupId);
                        userInLDAPGroupEntity.Save();
                    }
                }
            }
        }
예제 #2
0
 public LDAPUserInLDAPGroup(LDAPUserInLDAPGroup source)
     : base(source)
 {
 }
 public LDAPUserInLDAPGroup(Terrasoft.Configuration.LDAPUserInLDAPGroup source)
     : base(source)
 {
     this.CopyEntityLookupProperties(source);
 }