コード例 #1
0
ファイル: CreateEntryDialog.cs プロジェクト: MrJoe/lat
        public CreateEntryDialog(Connection connection, Template theTemplate)
        {
            if (connection == null)
                throw new ArgumentNullException("connection");
            if (theTemplate == null)
                throw new ArgumentNullException("theTemplate");

            conn = connection;
            t = theTemplate;
            isTemplate = true;

            Init ();

            foreach (string s in t.Classes) {
                attrListStore.AppendValues ("objectClass", s, "Optional");
                _objectClass.Add (s);
            }

            showAttributes ();

            createEntryDialog.Icon = Global.latIcon;

            createEntryDialog.Run ();

                createEntryDialog.Run ();

            createEntryDialog.Destroy ();
        }
コード例 #2
0
ファイル: LdapEntryAnalyzer.cs プロジェクト: MrJoe/lat
        public static string[] CheckRequiredAttributes(Connection conn, LdapEntry entry)
        {
            List<string> missingAttributes = new List<string> ();

            LdapAttribute objAttr = entry.getAttribute ("objectClass");
            if (objAttr == null)
                return null;

            foreach (string o in objAttr.StringValueArray) {
                if (o.Equals ("top"))
                    continue;

                string[] reqs = conn.Data.GetRequiredAttrs (o);
                if (reqs == null)
                    continue;

                foreach (string r in reqs) {
                    if (r.Equals ("cn"))
                        continue;

                    if (IsAttributeEmpty (entry.getAttribute (r))) {
                        missingAttributes.Add (r);
                        continue;
                    }
                }
            }

            return missingAttributes.ToArray();
        }
コード例 #3
0
ファイル: LoginDialog.cs プロジェクト: MrJoe/lat
        public LoginDialog(Connection connection, string msg)
        {
            Init ();

            conn = connection;
            msgLabel.Text = msg;
            isRelogin = true;
        }
コード例 #4
0
ファイル: TemplateEditorDialog.cs プロジェクト: MrJoe/lat
        public TemplateEditorDialog(Connection connection)
        {
            conn = connection;

            Init ();

            templateEditorDialog.Run ();
            templateEditorDialog.Destroy ();
        }
コード例 #5
0
ファイル: Message.cs プロジェクト: EventStore/csharp-ldap
        private bool waitForReply_Renamed_Field = true; // true if wait for reply

        #endregion Fields

        #region Constructors

        internal Message(LdapMessage msg, int mslimit, Connection conn, MessageAgent agent, LdapMessageQueue queue, BindProperties bindprops)
        {
            InitBlock();
            this.msg = msg;
            this.conn = conn;
            this.agent = agent;
            this.queue = queue;
            this.mslimit = mslimit;
            this.msgId = msg.MessageID;
            this.bindprops = bindprops;
            return ;
        }
コード例 #6
0
ファイル: ViewDataTreeView.cs プロジェクト: MrJoe/lat
        public ViewDataTreeView(Connection connection, Gtk.Window parent)
            : base()
        {
            conn = connection;
            parentWindow = parent;

            this.Selection.Mode = Gtk.SelectionMode.Multiple;

            this.ButtonPressEvent += new ButtonPressEventHandler (OnRightClick);
            this.RowActivated += new RowActivatedHandler (OnRowActivated);
            this.Selection.Changed += (object o, EventArgs args) => {};
            this.ShowAll ();
        }
コード例 #7
0
ファイル: UserDefaultValuesDialog.cs プロジェクト: MrJoe/lat
        public UserDefaultValuesDialog(ViewPlugin plugin, Connection connection)
        {
            vp = plugin;
            conn = connection;

            ui = new Glade.XML (null, "dialogs.glade", "defaultValuesDialog", null);
            ui.Autoconnect (this);

            passwordEntry.Sensitive = false;
            SetDefaultValues ();

            defaultValuesDialog.Run ();
            defaultValuesDialog.Destroy ();
        }
コード例 #8
0
ファイル: TemplatesDialog.cs プロジェクト: MrJoe/lat
        public TemplatesDialog(Connection connection)
        {
            conn = connection;

            ui = new Glade.XML (null, "lat.glade", "templatesDialog", null);
            ui.Autoconnect (this);

            setupTreeViews ();
            listTemplates ();

            templatesDialog.Icon = Global.latIcon;
            templatesDialog.Resize (320, 300);

            templatesDialog.Run ();
            templatesDialog.Destroy ();
        }
コード例 #9
0
ファイル: NewEntryDialog.cs プロジェクト: MrJoe/lat
        public NewEntryDialog(Connection connection, string dn)
        {
            conn = connection;
            _dn = dn;

            ui = new Glade.XML (null, "lat.glade", "newEntryDialog", null);
            ui.Autoconnect (this);

            entryRadioButton.Label += String.Format ("\n({0})", _dn);

            createCombos ();

            newEntryDialog.Icon = Global.latIcon;
            newEntryDialog.Run ();
            newEntryDialog.Destroy ();
        }
コード例 #10
0
ファイル: HostsViewDialog.cs プロジェクト: MrJoe/lat
        public HostsViewDialog(Connection connection, LdapEntry le)
            : base(connection, null)
        {
            isEdit = true;
            currentEntry = le;

            Init ();

            string hostName = conn.Data.GetAttributeValueFromEntry (currentEntry, "cn");
            hostDialog.Title = hostName + " Properties";
            hostNameEntry.Text = hostName;

            ipEntry.Text = conn.Data.GetAttributeValueFromEntry (currentEntry, "ipHostNumber");
            descriptionEntry.Text = conn.Data.GetAttributeValueFromEntry (currentEntry, "description");

            hostDialog.Run ();
            hostDialog.Destroy ();
        }
コード例 #11
0
ファイル: EditAdComputerViewDialog.cs プロジェクト: MrJoe/lat
        public EditAdComputerViewDialog(Connection connection, LdapEntry le)
            : base(connection, null)
        {
            currentEntry = le;

            Init ();

            computerNameLabel.Text = conn.Data.GetAttributeValueFromEntry (currentEntry, "cn");

            string cpName = (string) conn.Data.GetAttributeValueFromEntry (currentEntry, "cn");
            computerNameEntry.Text = cpName.ToUpper();

            editAdComputerDialog.Title = cpName + " Properties";

            dnsNameEntry.Text = conn.Data.GetAttributeValueFromEntry (currentEntry, "dNSHostName");
            descriptionEntry.Text = conn.Data.GetAttributeValueFromEntry (currentEntry, "description");

            osNameEntry.Text = conn.Data.GetAttributeValueFromEntry (currentEntry, "operatingSystem");
            osVersionEntry.Text = conn.Data.GetAttributeValueFromEntry (currentEntry, "operatingSystemVersion");
            osServicePackEntry.Text = conn.Data.GetAttributeValueFromEntry (currentEntry, "operatingSystemServicePack");

            locationEntry.Text = conn.Data.GetAttributeValueFromEntry (currentEntry, "location");

            string manName = conn.Data.GetAttributeValueFromEntry (currentEntry, "managedBy");
            manNameEntry.Text = manName;

            if (manName != "" || manName != null)
                updateManagedBy (manName);

            editAdComputerDialog.Icon = Global.latIcon;
            editAdComputerDialog.Run ();

            while (missingValues || errorOccured) {
                if (missingValues)
                    missingValues = false;
                else if (errorOccured)
                    errorOccured = false;

                editAdComputerDialog.Run ();
            }

            editAdComputerDialog.Destroy ();
        }
コード例 #12
0
ファイル: GroupsViewDialog.cs プロジェクト: MrJoe/lat
        public GroupsViewDialog(Connection connection, LdapEntry le)
            : base(connection, null)
        {
            currentEntry = le;

            isEdit = true;

            Init ();

            string groupName = conn.Data.GetAttributeValueFromEntry (currentEntry, "cn");

            groupDialog.Title = groupName + " Properties";
            groupNameEntry.Text = groupName;
            descriptionEntry.Text = conn.Data.GetAttributeValueFromEntry (currentEntry, "description");

            LdapAttribute attr = currentEntry.getAttribute ("member");
            if (attr != null) {
                foreach (string s in attr.StringValueArray) {
                    LdapEntry userEntry = conn.Data.GetEntry (s);
                    LdapAttribute userNameAttribute = userEntry.getAttribute ("name");

                    currentMemberStore.AppendValues (userNameAttribute.StringValue);
                    currentMembers.Add (userNameAttribute.StringValue);
                }
            }

            populateUsers ();

            groupDialog.Run ();

            while (missingValues || errorOccured){
                if (missingValues)
                    missingValues = false;
                else if (errorOccured)
                    errorOccured = false;

                groupDialog.Run ();
            }

            groupDialog.Destroy ();
        }
コード例 #13
0
ファイル: HostsViewDialog.cs プロジェクト: MrJoe/lat
        public HostsViewDialog(Connection connection, string newContainer)
            : base(connection, newContainer)
        {
            Init ();

            hostDialog.Icon = Global.latIcon;
            hostDialog.Title = "Add Computer";

            hostDialog.Run ();

            while (missingValues || errorOccured) {
                if (missingValues)
                    missingValues = false;
                else if (errorOccured)
                    errorOccured = false;

                hostDialog.Run ();
            }

            hostDialog.Destroy ();
        }
コード例 #14
0
ファイル: NewContactsViewDialog.cs プロジェクト: MrJoe/lat
        public NewContactsViewDialog(Connection connection, string newContainer)
            : base(connection, newContainer)
        {
            Init ();

            newContactDialog.Icon = Global.latIcon;
            newContactDialog.Title = "New Contact";

            newContactDialog.Run ();

            while (missingValues || errorOccured) {

                if (missingValues)
                    missingValues = false;
                else if (errorOccured)
                    errorOccured = false;

                newContactDialog.Run ();
            }

            newContactDialog.Destroy ();
        }
コード例 #15
0
ファイル: TemplateEditorDialog.cs プロジェクト: MrJoe/lat
        public TemplateEditorDialog(Connection connection, Template theTemplate)
        {
            conn = connection;
            _isEdit = true;

            t = theTemplate;

            Init ();

            nameEntry.Text = t.Name;
            nameEntry.Sensitive = false;

            foreach (string s in t.Classes) {
                objListStore.AppendValues (s);
                _objectClass.Add (s);
            }

            ShowAttributes ();

            templateEditorDialog.Run ();
            templateEditorDialog.Destroy ();
        }
コード例 #16
0
ファイル: GroupsViewDialog.cs プロジェクト: MrJoe/lat
        public GroupsViewDialog(Connection connection, string newContainer)
            : base(connection, newContainer)
        {
            Init ();

            populateUsers ();

            groupDialog.Title = "Add Group";
            groupIDSpinButton.Value = conn.Data.GetNextGID ();

            groupDialog.Icon = Global.latIcon;
            groupDialog.Run ();

            while (missingValues || errorOccured) {
                if (missingValues)
                    missingValues = false;
                else if (errorOccured)
                    errorOccured = false;

                groupDialog.Run ();
            }

            groupDialog.Destroy ();
        }
コード例 #17
0
ファイル: NewAdUserViewDialog.cs プロジェクト: MrJoe/lat
        public NewAdUserViewDialog(Connection connection, string newContainer)
            : base(connection, newContainer)
        {
            Init ();

            groupList = GetGroups ();

            createCombo ();

            newAdUserDialog.Icon = Global.latIcon;
            newAdUserDialog.Run ();

            while (missingValues || errorOccured) {

                if (missingValues)
                    missingValues = false;
                else if (errorOccured)
                    errorOccured = false;

                newAdUserDialog.Run ();
            }

            newAdUserDialog.Destroy ();
        }
コード例 #18
0
ファイル: LdapTreeView.cs プロジェクト: MrJoe/lat
        public void OnDragDataReceived(object o, DragDataReceivedArgs args)
        {
            Log.Debug ("BEGIN OnDragDataReceived");

            bool success = false;

            string data = System.Text.Encoding.UTF8.GetString (
                    args.SelectionData.Data);

            Gtk.TreeModel model;
            Gtk.TreeIter iter;

            if (!this.Selection.GetSelected (out model, out iter))
                return;

            if (!IsSingle) {
                string serverName = FindServerName (iter, model);
                if (serverName == null)
                    return;

                conn = Global.Connections [serverName];
            }

            switch (args.Info) {

            case 0:
            {
                string[] uri_list = Regex.Split (data, "\r\n");

                Util.ImportData (conn, parent, uri_list);

                success = true;
                break;
            }

            case 1:
                Util.ImportData (conn, parent, data);
                success = true;
                break;

            }

            Log.Debug ("import success: {0}", success.ToString());

            Gtk.Drag.Finish (args.Context, success, false, args.Time);

            Log.Debug ("END OnDragDataReceived");
        }
コード例 #19
0
ファイル: LdapTreeView.cs プロジェクト: MrJoe/lat
        public void OnNewEntryActivate(object o, EventArgs args)
        {
            string dn = GetSelectedDN ();

            TreeModel model;
            TreeIter iter;

            if (this.Selection.GetSelected (out model, out iter)) {

                string serverName = FindServerName (iter, model);
                if (serverName == null)
                    return;

                if (!IsSingle)
                    conn = Global.Connections [serverName];

                new NewEntryDialog (conn, dn);
            }
        }
コード例 #20
0
ファイル: Message.cs プロジェクト: EventStore/csharp-ldap
 private void cleanup()
 {
     stopTimer(); // Make sure timer stopped
     try
     {
         acceptReplies = false;
         if (conn != null)
         {
             conn.removeMessage(this);
         }
         // Empty out any accumuluated replies
         if (replies != null)
         {
             while (!(replies.Count == 0))
             {
                 System.Object temp_object;
                 temp_object = replies[0];
                 replies.RemoveAt(0);
                 System.Object generatedAux = temp_object;
             }
         }
     }
     catch (System.Exception ex)
     {
         // nothing
     }
     // Let GC clean up this stuff, leave name in case finalized is called
     conn = null;
     msg = null;
     // agent = null;  // leave this reference
     queue = null;
     //replies = null; //leave this since we use it as a semaphore
     bindprops = null;
     return ;
 }
コード例 #21
0
ファイル: LdapTreeView.cs プロジェクト: MrJoe/lat
        void AddEntry(string name, Connection conn, TreeIter iter)
        {
            try {

                Pixbuf pb = Pixbuf.LoadFromResource ("x-directory-normal.png");
             		LdapEntry[] ldapEntries = conn.Data.GetEntryChildren (name);

                foreach (LdapEntry le in ldapEntries) {

                    Log.Debug ("\tchild: {0}", le.DN);
                    DN dn = new DN (le.DN);
                    RDN rdn = (RDN) dn.RDNs[0];

                    TreeIter newChild;

                    newChild = browserStore.AppendValues (iter, pb, le.DN, rdn.Value);
                    browserStore.AppendValues (newChild, pb, "", "");
                }

            } catch {

                string	msg = Mono.Unix.Catalog.GetString (
                    "Unable to read data from server");

                HIGMessageDialog dialog = new HIGMessageDialog (
                    parent,
                    0,
                    Gtk.MessageType.Error,
                    Gtk.ButtonsType.Ok,
                    "Network error",
                    msg);

                dialog.Run ();
                dialog.Destroy ();
            }
        }
コード例 #22
0
ファイル: PosixUserViewPlugin.cs プロジェクト: MrJoe/lat
 public override void OnEditEntry(Connection conn, LdapEntry le)
 {
     new EditUserViewDialog (conn, le);
 }
コード例 #23
0
ファイル: PosixUserViewPlugin.cs プロジェクト: MrJoe/lat
 public override void OnSetDefaultValues(Connection conn)
 {
     new UserDefaultValuesDialog (this, conn);
     Log.Debug ("this.PluginConfiguration.Defaults.Count: {0}", this.PluginConfiguration.Defaults.Count);
 }
コード例 #24
0
		/*
		* Constructors
		*/
		
		
		/// <summary> Constructs a new LdapConnection object, which will use the supplied
		/// class factory to construct a socket connection during
		/// LdapConnection.connect method.
		/// 
		/// </summary>
		/// <param name="factory">    An object capable of producing a Socket.
		/// 
		/// </param>
		public LdapConnection()
		{
			InitBlock();
			// Get a unique connection name for debug
			conn = new Connection();
			return ;
		}
コード例 #25
0
ファイル: PosixUserViewPlugin.cs プロジェクト: MrJoe/lat
 public override void OnAddEntry(Connection conn)
 {
     new NewUserViewDialog (conn, this.DefaultNewContainer, this.PluginConfiguration.Defaults);
 }
コード例 #26
0
		/// <summary> Synchronously disconnect from the server
		/// 
		/// </summary>
		/// <param name="how">true if application call disconnect API, false if finalize.
		/// </param>
		private void  Disconnect(LdapConstraints cons, bool how)
		{
			// disconnect doesn't affect other clones
			// If not a clone, distroys connection
			conn = conn.destroyClone(how);
			return ;
		}
コード例 #27
0
		//*************************************************************************
		// connect methods
		//*************************************************************************
		
		/// <summary> 
		/// Connects to the specified host and port.
		/// 
		/// If this LdapConnection object represents an open connection, the
		/// connection is closed first before the new connection is opened.
		/// At this point, there is no authentication, and any operations are
		/// conducted as an anonymous client.
		/// 
		///  When more than one host name is specified, each host is contacted
		/// in turn until a connection can be established.
		/// 
		/// </summary>
		/// <param name="host">A host name or a dotted string representing the IP address
		/// of a host running an Ldap server. It may also
		/// contain a list of host names, space-delimited. Each host
		/// name can include a trailing colon and port number.
		/// 
		/// </param>
		/// <param name="port">The TCP or UDP port number to connect to or contact.
		/// The default Ldap port is 389. The port parameter is
		/// ignored for any host hame which includes a colon and
		/// port number.
		/// 
		/// </param>
		/// <exception> LdapException A general exception which includes an error
		/// message and an Ldap error code.
		/// 
		/// </exception>
		public virtual void  Connect(System.String host, int port)
		{
			// connect doesn't affect other clones
			// If not a clone, destroys old connection.
			// Step through the space-delimited list
			SupportClass.Tokenizer hostList = new SupportClass.Tokenizer(host, " ");
			System.String address = null;
			
			int specifiedPort;
			int colonIndex; //after the colon is the port
			while (hostList.HasMoreTokens())
			{
				try
				{
					specifiedPort = port;
					address = hostList.NextToken();
					colonIndex = address.IndexOf((System.Char) ':');
					if (colonIndex != - 1 && colonIndex + 1 != address.Length)
					{
						//parse Port out of address
						try
						{
							specifiedPort = System.Int32.Parse(address.Substring(colonIndex + 1));
							address = address.Substring(0, (colonIndex) - (0));
						}
						catch (System.Exception e)
						{
							throw new System.ArgumentException(ExceptionMessages.INVALID_ADDRESS);
						}
					}
					// This may return a different conn object
					// Disassociate this clone with the underlying connection.
					conn = conn.destroyClone(true);
					conn.connect(address, specifiedPort);
					break;
				}
				catch (LdapException LE)
				{
					if (!hostList.HasMoreTokens())
						throw LE;
				}
			}
			return ;
		}
コード例 #28
0
ファイル: LdapTreeView.cs プロジェクト: MrJoe/lat
        void OnRenameActivate(object o, EventArgs args)
        {
            string dn = GetSelectedDN ();
            TreeIter iter = GetSelectedIter ();

            string serverName = FindServerName (iter, browserStore);
            if (serverName == null)
                return;

            if (!IsSingle)
                conn = Global.Connections [serverName];

            if (dn == conn.Settings.Host)
                return;

            RenameEntryDialog red = new RenameEntryDialog (conn, dn);

            TreeModel model;
            TreeIter iter2, parentIter;

            if (red.RenameHappened) {
                if (this.Selection.GetSelected (out model, out iter2)) {
                    browserStore.IterParent (out parentIter, iter2);
                    TreePath tp = browserStore.GetPath (parentIter);
                    this.CollapseRow (tp);
                    this.ExpandRow (tp, false);
                }
            }
        }
コード例 #29
0
ファイル: LdapTreeView.cs プロジェクト: MrJoe/lat
        void OnExportActivate(object o, EventArgs args)
        {
            string dn = GetSelectedDN ();

            if (dn.Equals (null))
                return;

            TreeIter iter = GetSelectedIter ();
            string serverName = FindServerName (iter, browserStore);
            if (serverName == null)
                return;

            if (!IsSingle)
                conn = Global.Connections [serverName];

            Util.ExportData (conn, this.parent, dn);
        }
コード例 #30
0
ファイル: LdapTreeView.cs プロジェクト: MrJoe/lat
        void ldapRowExpanded(object o, RowExpandedArgs args)
        {
            string name = null;
            name = (string) browserStore.GetValue (args.Iter, (int)TreeCols.DN);
            if (name == "Servers")
                return;

            TreeIter child;
            browserStore.IterChildren (out child, args.Iter);

            string childName = (string)browserStore.GetValue (child, (int)TreeCols.DN);
            if (childName != "")
                return;

            browserStore.Remove (ref child);

            Log.Debug ("Row expanded {0}", name);

            string serverName = FindServerName (args.Iter, browserStore);
            if (!IsSingle) {
                conn = Global.Connections [serverName];
            }

            try {

                if (!conn.IsConnected)
                    conn.Connect ();

            } catch (Exception e) {

                browserStore.AppendValues (args.Iter, null, "", "");

                HIGMessageDialog dialog = new HIGMessageDialog (
                    parent,
                    0,
                    Gtk.MessageType.Error,
                    Gtk.ButtonsType.Ok,
                    "Connection error",
                    e.Message);

                dialog.Run ();
                dialog.Destroy ();

                return;
            }

            if (name == serverName) {

                Pixbuf pb = Pixbuf.LoadFromResource ("x-directory-remote-server.png");
                TreeIter i = browserStore.AppendValues (args.Iter, pb, conn.DirectoryRoot, conn.DirectoryRoot);
                browserStore.AppendValues (i, null, "", "");

            } else {

                AddEntry (name, conn, args.Iter);

            }

            TreePath path = browserStore.GetPath (args.Iter);
            this.ExpandRow (path, false);
        }