partial void OnExport(NSObject sender)
        {
            if (!ValidateExport())
            {
                return;
            }
            UIErrorHelper.CheckedExec(delegate
            {
                StringBuilder sb = new StringBuilder();
                var start        = 0;
                var end          = _resultList.Count;
                if (ScopeComboBox.SelectedIndex == (int)ExportScope.CURR_PAGE)
                {
                    start = (_currPage - 1) * _pageSize;
                    end   = _currPage * _pageSize > _resultList.Count ? _resultList.Count : _currPage * _pageSize;
                }
                HashSet <string> attrToExport = new HashSet <string>();
                if (AllReturnAttrCheckBox.State == NSCellStateValue.On)
                {
                    foreach (var item in _returnedAttrList)
                    {
                        attrToExport.Add(item);
                    }
                }
                else
                {
                    foreach (var item in _attrToExportDs.attrList)
                    {
                        attrToExport.Add(item);
                    }
                }

                foreach (var item in attrToExport)
                {
                    sb.Append(item + ",");
                }
                sb.Append(Environment.NewLine);
                for (var i = start; i < end; i++)
                {
                    foreach (var item in attrToExport)
                    {
                        sb.Append("\"");
                        if (_resultList[i].NodeProperties.ContainsKey(item))
                        {
                            foreach (var val in _resultList[i].NodeProperties[item].Values)
                            {
                                sb.Append(val.StringValue + " ");
                            }
                        }
                        sb.Append("\"");
                        sb.Append(",");
                    }
                    sb.Append(Environment.NewLine);
                }
                if (FileIOUtil.WriteAllTextToFile(sb.ToString(), "Export Result", new string[] { "csv" }))
                {
                    UIErrorHelper.ShowInformation(VMDirConstants.STAT_RES_EXPO_SUCC);
                }
            });
        }
Exemple #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.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();
            }
        }
Exemple #3
0
        public virtual void PerformDelete()
        {
            ConfirmationDialogController cwc = new ConfirmationDialogController("Are you sure?");
            nint result = NSApplication.SharedApplication.RunModalForWindow(cwc.Window);

            if (result == (nint)VMIdentityConstants.DIALOGOK)
            {
                UIErrorHelper.CheckedExec(delegate()
                {
                    ServerDTO.Connection.DeleteObject(Dn);
                    ScopeNode node = this.Parent;
                    if (node != null)
                    {
                        node.Children.Remove(this);
                        if (node is DirectoryNode)
                        {
                            (node as DirectoryNode).ReloadChildren();
                        }
                        NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadOutlineView", node);
                        NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadTableView", node);
                        UIErrorHelper.ShowInformation(VMDirConstants.STAT_OBJ_DEL_SUCC);
                    }
                    else
                    {
                        UIErrorHelper.ShowInformation(VMDirConstants.STAT_BASE_OBJ_DEL_SUCC);
                    }
                });
            }
        }
        partial void OnStoreQueryToolBarItem(NSObject sender)
        {
            UIErrorHelper.CheckedExec(delegate()
            {
                var data = GetQuery();
                if (data == null)
                {
                    return;
                }

                using (var ms = new MemoryStream())
                {
                    var xmlSerializer = new XmlSerializer(data.GetType());
                    xmlSerializer.Serialize(ms, data);

                    var save = NSSavePanel.SavePanel;
                    save.AllowedFileTypes = new string[] { "xml" };
                    save.Title            = "Store Query";
                    nint result           = save.RunModal();
                    if (result == (int)1)
                    {
                        string path = save.Url.Path;
                        File.WriteAllBytes(path, ms.ToArray());
                        UIErrorHelper.ShowInformation(VMDirConstants.STAT_QUERY_STORE_SUCC);
                    }
                }
            });
        }
Exemple #5
0
        public override void PerformDelete()
        {
            ConfirmationDialogController cwc = new ConfirmationDialogController("Are you sure?");
            nint result = NSApplication.SharedApplication.RunModalForWindow(cwc.Window);

            if (result == (nint)VMIdentityConstants.DIALOGOK)
            {
                UIErrorHelper.CheckedExec(delegate()
                {
                    ServerDTO.Connection.DeleteObject(Dn);
                    NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadResultOutlineView", this);
                    UIErrorHelper.ShowInformation(VMDirConstants.STAT_OBJ_DEL_SUCC);
                });
            }
        }
Exemple #6
0
        public void ShowAddUser()
        {
            UserDTO userDTO          = new UserDTO();
            AddNewUserController awc = new AddNewUserController(userDTO);
            nint res = NSApplication.SharedApplication.RunModalForWindow(awc.Window);

            if (res == (nint)VMIdentityConstants.DIALOGOK)
            {
                UIErrorHelper.CheckedExec(delegate()
                {
                    LdapMod[] user = new LdapMod[6];
                    user[0]        = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_GIVEN_NAME, new string[] {
                        userDTO.FirstName,
                        null
                    });
                    user[1] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_SN, new string[] {
                        userDTO.LastName,
                        null
                    });
                    user[2] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_CN, new string[] {
                        userDTO.Cn,
                        null
                    });
                    user[3] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_KRB_UPN, new string[] {
                        userDTO.UPN,
                        null
                    });
                    user[4] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_SAM_ACCOUNT_NAME, new string[] {
                        userDTO.SAMAccountName,
                        null
                    });
                    user[5] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_OBJECT_CLASS, new string[] {
                        VMDirConstants.USER_OC,
                        null
                    });
                    string dn = string.Format("cn={0},{1}", userDTO.Cn, Dn);
                    ServerDTO.Connection.AddObject(dn, user);
                    UIErrorHelper.ShowInformation(VMDirConstants.STAT_USR_ADD_SUCC);
                    var oc = Utilities.GetObjectClassList(ServerDTO, dn, LdapScope.SCOPE_BASE);
                    this.Children.Insert(0, new DirectoryNode(dn, oc, ServerDTO, this));
                    //ReloadChildren();
                    RefreshProperties();
                    NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadOutlineView", this);
                    NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadTableView", this);
                });
            }
        }
Exemple #7
0
 public void RestUserPassword(object sender, EventArgs e)
 {
     ResetPasswordWindowController cwc = new ResetPasswordWindowController(Dn);
     nint result = NSApplication.SharedApplication.RunModalForWindow(cwc.Window);
     if (result == (nint)VMIdentityConstants.DIALOGOK)
     {
         UIErrorHelper.CheckedExec(delegate ()
         {
             LdapMod[] mod = new LdapMod[1];
             mod[0] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_REPLACE, VMDirConstants.ATTR_USER_PASSWORD, new string[] {
                 cwc.Password,
                 null
             });
             ServerDTO.Connection.ModifyObject(cwc.Dn, mod);
             UIErrorHelper.ShowInformation(VMDirConstants.STAT_PWD_RESET_SUCC);
             ReloadChildren();
             NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadTableView", this);
         });
     }
 }
Exemple #8
0
 //Launch Dialogs
 public virtual void AddUserToGroup(object sender, EventArgs e)
 {
     AddGroupByCNWindowController gwc = new AddGroupByCNWindowController(ServerDTO);
     nint result = NSApplication.SharedApplication.RunModalForWindow(gwc.Window);
     if (result == (nint)VMIdentityConstants.DIALOGOK)
     {
         UIErrorHelper.CheckedExec(delegate ()
         {
             string[] values = new string[2];
             values[1] = null;
             values[0] = Dn;
             LdapMod[] ldapVal = new LdapMod[1];
             ldapVal[0] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_MEMBER, values);
             ServerDTO.Connection.ModifyObject(gwc.DNText, ldapVal);
             UIErrorHelper.ShowInformation(VMDirConstants.STAT_MEMBER_ADD_SUCC);
             ReloadChildren();
             RefreshProperties();
             NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadTableView", this);
         });
     }
 }
Exemple #9
0
        public void ShowAddGroup()
        {
            GroupDTO dto = new GroupDTO();
            AddNewGroupController agc = new AddNewGroupController(dto);
            nint res = NSApplication.SharedApplication.RunModalForWindow(agc.Window);

            if (res == (nint)VMIdentityConstants.DIALOGOK)
            {
                UIErrorHelper.CheckedExec(delegate()
                {
                    LdapMod[] user = new LdapMod[4];
                    user[0]        = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_CN, new string[] {
                        dto.cn,
                        null
                    });
                    user[1] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_GROUPTYPE, new string[] {
                        dto.groupType.ToString(),
                        null
                    });
                    user[2] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_SAM_ACCOUNT_NAME, new string[] {
                        dto.sAMAccountName,
                        null
                    });
                    user[3] = new LdapMod((int)LdapMod.mod_ops.LDAP_MOD_ADD, VMDirConstants.ATTR_OBJECT_CLASS, new string[] {
                        dto.objectClass,
                        null
                    });
                    string dn = string.Format("cn={0},{1}", dto.cn, Dn);
                    ServerDTO.Connection.AddObject(dn, user);
                    UIErrorHelper.ShowInformation(VMDirConstants.STAT_GRP_ADD_SUCC);
                    var oc = Utilities.GetObjectClassList(ServerDTO, dn, LdapScope.SCOPE_BASE);
                    this.Children.Insert(0, new DirectoryNode(dn, oc, ServerDTO, this));
                    //ReloadChildren();
                    RefreshProperties();
                    NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadOutlineView", this);
                    NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadTableView", this);
                });
            }
        }
 partial void OnLoadQueryToolBarItem(NSObject sender)
 {
     UIErrorHelper.CheckedExec(delegate
     {
         var open = NSOpenPanel.OpenPanel;
         open.AllowedFileTypes = new string[] { "xml" };
         open.Title            = "Load Query";
         nint result           = open.RunModal();
         if (result == (int)1)
         {
             string path = open.Url.Path;
             try
             {
                 _qdto = LoadQuryOfType(typeof(BuildQueryDTO), path) as BuildQueryDTO;
             }
             catch (Exception)
             {
                 _qdto = LoadQuryOfType(typeof(TextQueryDTO), path) as TextQueryDTO;
             }
             BindData();
             UIErrorHelper.ShowInformation(VMDirConstants.STAT_QUERY_LOAD_SUCC);
         }
     });
 }