Example #1
0
        public void ShowAddWindow()
        {
            SelectObjectClassWindowController swc = new SelectObjectClassWindowController(ServerDTO.Connection.SchemaManager);
            nint result = NSApplication.SharedApplication.RunModalForWindow(swc.Window);

            if (result == (nint)VMIdentityConstants.DIALOGOK)
            {
                CreateObjectWindowController cwc = new CreateObjectWindowController(swc.SelectedObject.Name, ServerDTO, Dn);
                nint res = NSApplication.SharedApplication.RunModalForWindow(cwc.Window);
                if (res == (nint)VMIdentityConstants.DIALOGOK)
                {
                    UIErrorHelper.CheckedExec(delegate()
                    {
                        var attr     = cwc._properties.Select(x => Utilities.MakeAttribute(x)).ToArray();
                        string newdn = cwc.Rdn + "," + Dn;
                        ServerDTO.Connection.AddObject(newdn, attr);
                        UIErrorHelper.ShowInformation(VMDirConstants.STAT_OBJ_ADD_SUCC);
                        var oc = Utilities.GetObjectClassList(ServerDTO, newdn, LdapScope.SCOPE_BASE);
                        this.Children.Insert(0, new DirectoryNode(newdn, oc, ServerDTO, this));
                        //ReloadChildren();
                        RefreshProperties();
                        NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadOutlineView", this);
                        NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadTableView", this);
                    });
                }
                swc.Dispose();
            }
        }
Example #2
0
        public void ShowAddWindow()
        {
            SelectObjectClassWindowController swc = new SelectObjectClassWindowController(ServerDTO.Connection.SchemaManager);
            nint result = NSApplication.SharedApplication.RunModalForWindow(swc.Window);

            if (result == (nint)VMIdentityConstants.DIALOGOK)
            {
                CreateObjectWindowController cwc = new CreateObjectWindowController(swc.SelectedObject, ServerDTO);
                nint res = NSApplication.SharedApplication.RunModalForWindow(cwc.Window);
                if (res == (nint)VMIdentityConstants.DIALOGOK)
                {
                    UIErrorHelper.CheckedExec(delegate() {
                        if (cwc._properties.Count > 0)
                        {
                            LdapMod[] user = new LdapMod[cwc._properties.Count];
                            int count      = 0;
                            foreach (var entry in cwc._properties)
                            {
                                string[] values = new string[2];
                                values [0]      = Utilities.LdapValueToString(entry.Value.Value);
                                if (string.IsNullOrEmpty(values [0]))
                                {
                                    continue;
                                }
                                values [1]   = null;
                                user [count] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, entry.Key, values);
                                count++;
                            }
                            string dn = string.Format("cn={0},{1}", Utilities.LdapValueToString(cwc._properties.First(x => x.Key == "cn").Value.Value), Name);
                            ServerDTO.Connection.AddObject(dn, user);
                            UIErrorHelper.ShowAlert("", "Successfully Added object");
                            ReloadChildren();
                            RefreshProperties();
                            NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadOutlineView", this);
                            NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadTableView", this);
                        }
                    });
                }
                VMDirSnapInEnvironment.Instance.MainWindow.EndSheet(cwc.Window);
                swc.Dispose();
            }
        }