예제 #1
0
        static void CreateForm(string objectClass, VMDirServerDTO dto)
        {
            var frm = new CreateForm(objectClass, dto);

            if (frm.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            var attributes = frm.Attributes.Select(x => LdapTypesService.MakeAttribute(x)).ToArray();

            var    cnVal = frm.Attributes.First(x => x.Key == "cn").Value.Value;
            string dn    = string.Format("cn={0},{1}", cnVal, "dc=vsphere,dc=local");

            dto.Connection.Add(dn, attributes);
        }
예제 #2
0
 public void AddObject()
 {
     MiscUtilsService.CheckedExec(delegate
     {
         var frmSelect = new SelectObjectClass(ServerDTO.Connection.SchemaManager);
         if (frmSelect.ShowDialog() == DialogResult.OK)
         {
             var frm = new CreateForm(frmSelect.SelectedObject, ServerDTO, Dn);
             if (frm.ShowDialog() == DialogResult.OK)
             {
                 var attributes = frm.Attributes.Select(x => LdapTypesService.MakeAttribute(x)).ToArray();
                 string newdn   = frm.Rdn + "," + Dn;
                 ServerDTO.Connection.AddObject(newdn, attributes);
                 ClearDummyNode();
                 var oc = VMDirUtil.Utilities.GetObjectClassList(ServerDTO, newdn, LdapScope.SCOPE_BASE);
                 this.Nodes.Insert(0, new DirectoryExpandableNode(newdn, oc, ServerDTO, PropertiesCtl));
                 MMCDlgHelper.ShowInformation(VMDirConstants.STAT_OBJ_ADD_SUCC);
             }
         }
     });
 }
예제 #3
0
        void Add()
        {
            try
            {
                /*
                 * string dn = string.Format("cn=def3,{0}", _name);
                 * DirectoryAttribute[] attr = new DirectoryAttribute[]
                 * {
                 * new DirectoryAttribute("cn", "def3"),
                 * new DirectoryAttribute("name", "def2"),
                 * new DirectoryAttribute("objectclass", "vmIdentity-Group"),
                 * new DirectoryAttribute("vmidentity-account", "def2")
                 * };
                 * ServerDTO.Connection.Add(dn, attr);
                 * this.Children.Add(new DirectoryNode(dn, ServerDTO));
                 */
                var frmSelect = new SelectObjectClass(ServerDTO.Connection.SchemaManager);
                if (SnapIn.Console.ShowDialog(frmSelect) == DialogResult.OK)
                {
                    var frm = new CreateForm(frmSelect.SelectedObject, ServerDTO);
                    if (SnapIn.Console.ShowDialog(frm) == DialogResult.OK)
                    {
                        var attributes = frm.Attributes.Select(x => LdapTypesService.MakeAttribute(x)).ToArray();

                        var    cnVal = frm.Attributes.First(x => x.Key == "cn").Value.Value;
                        string dn    = string.Format("cn={0},{1}", cnVal, _name);
                        ServerDTO.Connection.AddObject(dn, attributes);
                        this.Children.Add(new DirectoryNode(dn, ServerDTO));
                    }
                }
            }
            catch (Exception exp)
            {
                MiscUtilsService.ShowError(exp);
            }
        }