Exemplo n.º 1
0
    private void MemoflistView_MouseDoubleClick(object sender, MouseEventArgs e)
    {
        if (MemoflistView.SelectedItems.Count > 0)
        {
            ListViewItem selectedItem = MemoflistView.SelectedItems[0];
            if (selectedItem.Tag != null)
            {
                string distinguishedName = selectedItem.Tag.ToString();
                if (distinguishedName.Equals(_dirnode.DistinguishedName, StringComparison.InvariantCultureIgnoreCase))
                {
                    return;
                }
                ADUCPlugin plugin = _dirnode.Plugin as ADUCPlugin;
                if (plugin.Propertywindowhandles.ContainsKey(distinguishedName))
                {
                    Form f = plugin.Propertywindowhandles[distinguishedName] as Form;
                    f.BringToFront();
                    return;
                }

                string sLDAPPath = string.Format("LDAP://{0}/{1}", _dirnode.LdapContext.DomainName, distinguishedName);
                DirectoryEntry entry = new DirectoryEntry(sLDAPPath);
                if (entry == null)
                {
                    return;
                }

                object[] asProp = entry.Properties["objectClass"].Value as object[];

                // poke these in a list for easier reference
                List<string> liClasses = new List<string>();
                foreach (string s in asProp)
                {
                    liClasses.Add(s);
                }

                if (liClasses.Contains("computer"))
                {
                    ADUCDirectoryNode dirnode = new ADUCDirectoryNode(distinguishedName,
                    _dirnode.LdapContext, "computer",
                    Properties.Resources.computer, _dirnode.t, _dirnode.Plugin, _dirnode.IsDisabled);
                    ADComputerPropertiesDlg f = new ADComputerPropertiesDlg(base.container, _dirnode.PluginPage as ADUCPage, _plugin);
                    if (_dirnode.LdapContext.SchemaCache != null)
                    {
                        f.SetData(_plugin.HostInfo.creds, _plugin.HostInfo.hostName, dirnode.Text.Substring(3), dirnode, _dirnode.LdapContext.SchemaCache);
                        f.Show();
                    }
                }
                else if (liClasses.Contains("user"))
                {
                    ADUCDirectoryNode dirnode = new ADUCDirectoryNode(distinguishedName,
                    _dirnode.LdapContext, "user",
                    Properties.Resources.User, _dirnode.t, _dirnode.Plugin, _dirnode.IsDisabled);

                    List<object> dirnodes = new List<object>();
                    dirnodes.Add(dirnode);
                    ADUserPropertiesDlg f = new ADUserPropertiesDlg(base.container, _dirnode.PluginPage as ADUCPage, _plugin, dirnodes);
                    if (_dirnode.LdapContext.SchemaCache != null)
                    {
                        f.SetData(_plugin.HostInfo.creds, _plugin.HostInfo.hostName, dirnode.Text.Substring(3), dirnode, _dirnode.LdapContext.SchemaCache);
                        f.Show();
                    }
                }
                else if (liClasses.Contains("group"))
                {
                    ADUCDirectoryNode dirnode = new ADUCDirectoryNode(distinguishedName,
                    _dirnode.LdapContext, "group",
                    Properties.Resources.Group_48, _dirnode.t, _dirnode.Plugin, _dirnode.IsDisabled);
                    ADGroupPropertiesDlg f = new ADGroupPropertiesDlg(base.container, _dirnode.PluginPage as ADUCPage, _plugin, dirnode);
                    if (_dirnode.LdapContext.SchemaCache != null)
                    {
                        f.SetData(_plugin.HostInfo.creds, _plugin.HostInfo.hostName, dirnode.Text.Substring(3), dirnode, _dirnode.LdapContext.SchemaCache);
                        f.Show();
                    }
                }
                else if (liClasses.Contains("foreignSecurityPrincipal"))
                {
                    ADUCDirectoryNode dirnode = new ADUCDirectoryNode(distinguishedName,
                    _dirnode.LdapContext, "foreignSecurityPrincipal",
                    Properties.Resources.Group_48, _dirnode.t, _dirnode.Plugin, _dirnode.IsDisabled);
                    ADGroupPropertiesDlg f = new ADGroupPropertiesDlg(base.container, _dirnode.PluginPage as ADUCPage, _plugin, dirnode);
                    if (_dirnode.LdapContext.SchemaCache != null)
                    {
                        f.SetData(_plugin.HostInfo.creds, _plugin.HostInfo.hostName, dirnode.Text.Substring(3), dirnode, _dirnode.LdapContext.SchemaCache);
                        f.Show();
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
        private void MemoflistView_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (MemoflistView.SelectedItems.Count > 0)
            {
                ListViewItem selectedItem = MemoflistView.SelectedItems[0];
                if (selectedItem.Tag != null)
                {
                    string distinguishedName = selectedItem.Tag.ToString();
                    if (distinguishedName.Equals(_dirnode.DistinguishedName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        return;
                    }
                    ADUCPlugin plugin = _dirnode.Plugin as ADUCPlugin;
                    if (plugin.Propertywindowhandles.ContainsKey(distinguishedName))
                    {
                        Form f = plugin.Propertywindowhandles[distinguishedName] as Form;
                        f.BringToFront();
                        return;
                    }
                    string         sLDAPPath = string.Format("LDAP://{0}/{1}", _dirnode.LdapContext.DomainName, distinguishedName);
                    DirectoryEntry entry     = new DirectoryEntry(sLDAPPath, _dirnode.LdapContext.UserName, _dirnode.LdapContext.Password);
                    if (entry == null)
                    {
                        return;
                    }

                    object[] asProp = entry.Properties["objectClass"].Value as object[];

                    // poke these in a list for easier reference
                    List <string> liClasses = new List <string>();
                    foreach (string s in asProp)
                    {
                        liClasses.Add(s);
                    }

                    if (liClasses.Contains("computer"))
                    {
                        ADUCDirectoryNode dirnode = new ADUCDirectoryNode(distinguishedName,
                                                                          _dirnode.LdapContext, "computer",
                                                                          Properties.Resources.computer, _dirnode.t, _dirnode.Plugin, _dirnode.IsDisabled);
                        ADComputerPropertiesDlg f = new ADComputerPropertiesDlg(base.container, _dirnode.PluginPage as ADUCPage, _plugin);
                        if (_dirnode.LdapContext.SchemaCache != null)
                        {
                            f.SetData(_plugin.HostInfo.creds, _plugin.HostInfo.hostName, dirnode.Text.Substring(3), dirnode, _dirnode.LdapContext.SchemaCache);
                            f.Show();
                        }
                    }
                    else if (liClasses.Contains("group"))
                    {
                        ADUCDirectoryNode dirnode = new ADUCDirectoryNode(distinguishedName,
                                                                          _dirnode.LdapContext, "group",
                                                                          Properties.Resources.Group_48, _dirnode.t, _dirnode.Plugin, _dirnode.IsDisabled);
                        ADGroupPropertiesDlg f = new ADGroupPropertiesDlg(base.container, _dirnode.PluginPage as ADUCPage, _plugin, dirnode);
                        if (_dirnode.LdapContext.SchemaCache != null)
                        {
                            f.SetData(_plugin.HostInfo.creds, _plugin.HostInfo.hostName, dirnode.Text.Substring(3), dirnode, _dirnode.LdapContext.SchemaCache);
                            f.Show();
                        }
                    }
                    else if (liClasses.Contains("user"))
                    {
                        ADUCDirectoryNode dirnode = new ADUCDirectoryNode(distinguishedName,
                                                                          _dirnode.LdapContext, "user",
                                                                          Properties.Resources.User, _dirnode.t, _dirnode.Plugin, _dirnode.IsDisabled);

                        List <object> dirnodes = new List <object>();
                        dirnodes.Add(dirnode);
                        ADUserPropertiesDlg f = new ADUserPropertiesDlg(base.container, _dirnode.PluginPage as ADUCPage, _plugin, dirnodes);
                        if (_dirnode.LdapContext.SchemaCache != null)
                        {
                            f.SetData(_plugin.HostInfo.creds, _plugin.HostInfo.hostName, dirnode.Text.Substring(3), dirnode, _dirnode.LdapContext.SchemaCache);
                            f.Show();
                        }
                    }
                    else if (liClasses.Contains("foreignSecurityPrincipal"))
                    {
                        ADUCDirectoryNode dirnode = new ADUCDirectoryNode(distinguishedName,
                                                                          _dirnode.LdapContext, "foreignSecurityPrincipal",
                                                                          Properties.Resources.Group_48, _dirnode.t, _dirnode.Plugin, _dirnode.IsDisabled);
                        ADGroupPropertiesDlg f = new ADGroupPropertiesDlg(base.container, _dirnode.PluginPage as ADUCPage, _plugin, dirnode);
                        if (_dirnode.LdapContext.SchemaCache != null)
                        {
                            f.SetData(_plugin.HostInfo.creds, _plugin.HostInfo.hostName, dirnode.Text.Substring(3), dirnode, _dirnode.LdapContext.SchemaCache);
                            f.Show();
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
    public void DoPropertyPagesWork(ADUCDirectoryNode dirnode)
    {
        string newDn = null;

        if (dirnode != null)
        {
            string obj_type = dirnode.ObjectClass;
            DirectoryContext dirContext = dirnode.LdapContext;
            ADUCPlugin plugin = dirnode.Plugin as ADUCPlugin;

            if (plugin.Propertywindowhandles.ContainsKey(dirnode.DistinguishedName))
            {
                Form f = plugin.Propertywindowhandles[dirnode.DistinguishedName] as Form;
                f.BringToFront();
                return;
            }

            if (obj_type.Equals("top", StringComparison.InvariantCultureIgnoreCase) ||
            obj_type.Equals("user", StringComparison.InvariantCultureIgnoreCase))
            {
                List<object> dirnodes = new List<object>();
                dirnode.hn = plugin.HostInfo;
                dirnodes.Add(dirnode);
                ADUserPropertiesDlg f = new ADUserPropertiesDlg(base.container, this, plugin, dirnodes);
                if (dirContext.SchemaCache != null)
                {
                    f.SetData(
                    plugin.HostInfo.creds,
                    plugin.HostInfo.hostName,
                    dirnode.Text,
                    dirnode,
                    dirContext.SchemaCache);
                    f.Show();
                    if (f.AttrModified && f.newDn != null)
                    {
                        newDn = f.newDn;
                    }
                }
            }
            else if (obj_type.Equals("group", StringComparison.InvariantCultureIgnoreCase) ||
                    (obj_type.Equals("foreignSecurityPrincipal", StringComparison.InvariantCultureIgnoreCase)))
            {
                dirnode.hn = plugin.HostInfo;
                ADGroupPropertiesDlg f = new ADGroupPropertiesDlg(base.container, this, base.pi as ADUCPlugin, dirnode);
                if (dirContext.SchemaCache != null)
                {
                    f.SetData(plugin.HostInfo.creds, plugin.HostInfo.hostName, dirnode.Text, dirnode, dirContext.SchemaCache);
                    f.Show();
                    if (f.AttrModified && f.newDn != null)
                    {
                        newDn = f.newDn;
                    }
                }
            }
            else if (obj_type.Equals("organizationalUnit", StringComparison.InvariantCultureIgnoreCase))
            {
                ADOUPropertiesDlg f = new ADOUPropertiesDlg(base.container, this, base.pi as ADUCPlugin);
                if (dirContext.SchemaCache != null)
                {
                    f.SetData(plugin.HostInfo.creds, plugin.HostInfo.hostName, dirnode.Text, dirnode, dirContext.SchemaCache);
                    f.Show();
                    if (f.AttrModified && f.newDn != null)
                    {
                        newDn = f.newDn;
                    }
                }
            }
            else if (obj_type.Equals("computer", StringComparison.InvariantCultureIgnoreCase))
            {
                ADComputerPropertiesDlg f = new ADComputerPropertiesDlg(base.container, this, base.pi as ADUCPlugin);
                if (dirContext.SchemaCache != null)
                {
                    dirnode.hn = plugin.HostInfo;
                    f.SetData(plugin.HostInfo.creds, plugin.HostInfo.hostName, dirnode.Text, dirnode, dirContext.SchemaCache);
                    f.Show();
                    if (f.AttrModified && f.newDn != null)
                    {
                        newDn = f.newDn;
                    }
                }
            }
            else if (obj_type.Equals("serviceConnectionPoint", StringComparison.InvariantCultureIgnoreCase))
            {
                GenericPropertiesDlg f = new GenericPropertiesDlg(base.container, this, false);
                if (dirContext.SchemaCache != null)
                {
                    f.SetData(plugin.HostInfo.creds, plugin.HostInfo.hostName, dirnode.Text, dirnode, dirContext.SchemaCache);
                    f.Show();
                }
            }
            else if (dirnode.DistinguishedName == dirnode.LdapContext.RootDN)
            {
                DomainPropertiesDlg f = new DomainPropertiesDlg(base.container, this, base.pi as ADUCPlugin);
                if (dirContext.SchemaCache != null)
                {
                    f.SetData(plugin.HostInfo.creds, plugin.HostInfo.hostName, plugin.adContext.DomainName, dirnode, dirContext.SchemaCache);
                    f.Show();
                }
            }
            else
            {
                GenericPropertiesDlg f = new GenericPropertiesDlg(base.container, this, true);
                if (dirContext.SchemaCache != null)
                {
                    f.SetData(plugin.HostInfo.creds, plugin.HostInfo.hostName, dirnode.Text, dirnode, dirContext.SchemaCache);
                    f.Show();
                }
            }

            if (newDn != null)
            {
                dirnode.DistinguishedName = newDn;
                dirnode.Refresh();
                dirnode.IsModified = true;
                base.treeNode = dirnode;
            }
        }
    }