Esempio n. 1
0
        public void AddObjectClass(ObjectClassDTO dto)
        {
            MaintainSession(delegate()
            {
                List <LdapMod> objectclass = new List <LdapMod>();

                objectclass.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_CN, new string[] { dto.Name, null }));
                objectclass.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_OBJECT_CLASS, new string[] { VMDirConstants.DEFAULT_OBJECT_CLASS_NAME, null }));
                objectclass.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.SUB_CLASS_OF, new string[] { dto.SuperClass, null }));
                objectclass.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.OBJECT_CLASS_CATEGORY, new string[] { Convert.ToString(dto.GetObjectClassType()), null }));
                objectclass.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.GOVERNS_ID, new string[] { dto.GovernsID, null }));
                objectclass.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.SCHEMA_ID_GUID, new string[] { dto.Name, null }));
                objectclass.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.DEFAULT_OBJECT_CATEGORY, new string[] { "cn=schemacontext", null }));

                if (dto.Description != null && !String.IsNullOrWhiteSpace(dto.Description))
                {
                    objectclass.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.DESCRIPTION, new string[] { dto.Description, null }));
                }

                if (dto.Must != null && dto.Must.Count > 0)
                {
                    objectclass.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.SYSTEM_MUST_CONTAIN, ConvertListToLdapStringArray(dto.Must)));
                }

                if (dto.May != null && dto.May.Count > 0)
                {
                    objectclass.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.SYSTEM_MAY_CONTAIN, ConvertListToLdapStringArray(dto.May)));
                }

                if (dto.Aux != null && dto.Aux.Count > 0)
                {
                    objectclass.Add(new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.SYSTEM_AUX_CLASSES, ConvertListToLdapStringArray(dto.Aux)));
                }
                string dn = "cn=" + dto.Name + ",cn=schemacontext";
                ldConn.AddObject(dn, objectclass.ToArray());
            });
        }