public void OnEditActivate(object o, EventArgs args) { TreeModel model; if (this.Selection == null) { return; } TreePath[] tp = this.Selection.GetSelectedRows(out model); foreach (TreePath path in tp) { try { LdapEntry le = conn.Data.GetEntry(GetDN(path)); viewPlugin.OnEditEntry(conn, le); Populate(); } catch (Exception e) { Log.Debug(e); string msg = Mono.Unix.Catalog.GetString("Unable to edit entry"); HIGMessageDialog dialog = new HIGMessageDialog( parentWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Error", msg); dialog.Run(); dialog.Destroy(); } } }
private void Relogin() { try { if (useSSLCheckButton.Active) { conn.Settings.Encryption = EncryptionType.SSL; } if (conn.Settings.Encryption == EncryptionType.TLS) { conn.StartTLS(); } conn.Bind(userEntry.Text, passEntry.Text); } catch (Exception e) { string errorMsg = Mono.Unix.Catalog.GetString("Unable to re-login"); errorMsg += "\nError: " + e.Message; HIGMessageDialog dialog = new HIGMessageDialog( loginDialog, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Login error", errorMsg); dialog.Run(); dialog.Destroy(); } }
bool IsUserNameAvailable() { if (!Util.CheckUserName(conn, usernameEntry.Text)) { string format = Mono.Unix.Catalog.GetString( "A user with the username '{0}' already exists!"); string msg = String.Format(format, usernameEntry.Text); HIGMessageDialog dialog = new HIGMessageDialog( newUserDialog, 0, Gtk.MessageType.Warning, Gtk.ButtonsType.Ok, "User error", msg); dialog.Run(); dialog.Destroy(); return(false); } return(true); }
public void Populate() { if (viewPlugin.SearchBase == null) { viewPlugin.SearchBase = conn.DirectoryRoot; } try { LdapEntry[] data = conn.Data.Search(conn.DirectoryRoot, viewPlugin.Filter); Log.Debug("InsertData()\n\tbase: [{0}]\n\tfilter: [{1}]\n\tnumResults: [{2}]", viewPlugin.SearchBase, viewPlugin.Filter, data.Length); string msg = string.Format(Mono.Unix.Catalog.GetString("Found {0} entries"), data.Length); Global.Window.WriteStatusMessage(msg); DoInsert(data, viewPlugin.ColumnAttributes); } catch (Exception e) { HIGMessageDialog dialog = new HIGMessageDialog( parentWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Connection error", e.Message); dialog.Run(); dialog.Destroy(); } }
void DoInsert(LdapEntry[] objs, string[] attributes) { try { if (this.dataStore != null) { this.dataStore.Clear(); } foreach (LdapEntry le in objs) { string[] values = conn.Data.GetAttributeValuesFromEntry(le, attributes); string[] newvalues = new string [values.Length + 1]; values.CopyTo(newvalues, 0); newvalues [values.Length] = le.DN; this.dataStore.AppendValues(newvalues); } } catch { string msg = Mono.Unix.Catalog.GetString( "Unable to read data from server"); HIGMessageDialog dialog = new HIGMessageDialog( parentWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Network error", msg); dialog.Run(); dialog.Destroy(); } }
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(); } }
void OnRowActivated(object o, RowActivatedArgs args) { TreePath path = args.Path; TreeIter iter; if (this.dataStore.GetIter(out iter, path)) { string dn = (string)this.dataStore.GetValue(iter, dnColumn); try { viewPlugin.OnEditEntry(conn, conn.Data.GetEntry(dn)); } catch (Exception e) { Log.Debug(e); string msg = Mono.Unix.Catalog.GetString("Unable to edit entry"); HIGMessageDialog dialog = new HIGMessageDialog( parentWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Error", msg); dialog.Run(); dialog.Destroy(); } } }
void toggleSambaWidgets(bool state) { if (state && firstTimeSamba) { string msg = Mono.Unix.Catalog.GetString( "You must reset the password for this account in order to set a samba password."); HIGMessageDialog dialog = new HIGMessageDialog( editUserDialog, 0, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, "Setting a samba password", msg); dialog.Run(); dialog.Destroy(); } smbLoginScriptEntry.Sensitive = state; smbProfilePathEntry.Sensitive = state; smbHomePathEntry.Sensitive = state; smbHomeDriveEntry.Sensitive = state; smbExpireEntry.Sensitive = state; smbCanChangePwdEntry.Sensitive = state; smbMustChangePwdEntry.Sensitive = state; smbSetExpireButton.Sensitive = state; smbSetCanButton.Sensitive = state; smbSetMustButton.Sensitive = state; }
void modifyGroup(LdapEntry groupEntry, LdapModification[] mods) { if (groupEntry == null) { return; } try { conn.Data.Modify(groupEntry.DN, mods); } catch (Exception e) { string errorMsg = Mono.Unix.Catalog.GetString("Unable to modify group ") + groupEntry.DN; errorMsg += "\nError: " + e.Message; HIGMessageDialog dialog = new HIGMessageDialog( editUserDialog, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Error", errorMsg); dialog.Run(); dialog.Destroy(); } }
public static bool AddEntry(Connection conn, LdapEntry entry) { try { conn.Data.Add(entry); return(true); } catch (Exception e) { string errorMsg = Mono.Unix.Catalog.GetString("Unable to add entry ") + entry.DN; errorMsg += "\nError: " + e.Message; Log.Debug(e); HIGMessageDialog dialog = new HIGMessageDialog( null, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Add error", errorMsg); dialog.Run(); dialog.Destroy(); return(false); } }
public static bool ModifyEntry(Connection conn, string dn, LdapModification[] modList) { if (modList.Length == 0) { Log.Debug("No modifications to make to entry {0}", dn); return(false); } try { conn.Data.Modify(dn, modList); Log.Debug("Successfully modified entry {0}", dn); return(true); } catch (Exception e) { string errorMsg = Mono.Unix.Catalog.GetString("Unable to modify entry ") + dn; errorMsg += "\nError: " + e.Message; HIGMessageDialog dialog = new HIGMessageDialog( null, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Modify entry", errorMsg); dialog.Run(); dialog.Destroy(); return(false); } }
void OnRowExpanded(object o, RowExpandedArgs args) { string name = null; name = (string)schemaStore.GetValue(args.Iter, (int)TreeCols.ObjectName); if (name == "Servers") { return; } TreeIter child; schemaStore.IterChildren(out child, args.Iter); string childName = (string)schemaStore.GetValue(child, (int)TreeCols.ObjectName); if (childName != "") { return; } schemaStore.Remove(ref child); Log.Debug("Row expanded {0}", name); string serverName = FindServerName(args.Iter, schemaStore); Connection conn = Global.Connections [serverName]; try { Gdk.Pixbuf pb = Gdk.Pixbuf.LoadFromResource("text-x-generic.png"); string[] kids = GetChildren(name, conn); foreach (string s in kids) { schemaStore.AppendValues(args.Iter, pb, s); } TreePath path = schemaStore.GetPath(args.Iter); this.ExpandRow(path, false); } catch (Exception e) { schemaStore.AppendValues(args.Iter, null, ""); Log.Debug(e); string msg = Mono.Unix.Catalog.GetString( "Unable to read schema information from server"); HIGMessageDialog dialog = new HIGMessageDialog( parentWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Server error", msg); dialog.Run(); dialog.Destroy(); } }
public void OnSearchClicked(object o, EventArgs args) { TreeIter iter; if (!serverComboBox.GetActiveIter(out iter)) { return; } string profileName = (string)serverComboBox.Model.GetValue(iter, 0); Connection conn = Global.Connections [profileName]; LdapEntry[] searchResults = null; try { RfcFilter filter = new RfcFilter(filterEntry.Text); searchResults = conn.Data.Search(searchBaseButton.Label, filter.filterToString()); } catch (LdapLocalException ex) { HIGMessageDialog dialog = new HIGMessageDialog( mainWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Search error", string.Format("{0}.\n{1}", ex.Message, ex.LdapErrorMessage)); dialog.Run(); dialog.Destroy(); return; } if (searchResults == null) { HIGMessageDialog dialog = new HIGMessageDialog( mainWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Search error", Mono.Unix.Catalog.GetString("Invalid search filter.")); dialog.Run(); dialog.Destroy(); } else if (searchResults.Length > 0 && filterEntry.Text != "") { searchTreeView.UpdateSearchResults(searchResults); string msg = String.Format("Found {0} matching entries", searchResults.Length); appBar.Pop(); appBar.Push(msg); } }
public void OnOkClicked(object o, EventArgs args) { string oldDN = oldNameEntry.Text; string newDN = newNameEntry.Text; bool saveOld = saveOldNameCheckButton.Active; try { conn.Data.Rename(oldDN, newDN, saveOld); string msg = String.Format( Mono.Unix.Catalog.GetString( "Entry {0} has been renamed to {1}."), oldDN, newDN); HIGMessageDialog dialog = new HIGMessageDialog( renameEntryDialog, 0, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, "Entry renamed", msg); dialog.Run(); dialog.Destroy(); renameHappened = true; } catch (Exception e) { string errorMsg = Mono.Unix.Catalog.GetString("Unable to rename entry ") + oldDN; errorMsg += "\nError: " + e.Message; HIGMessageDialog dialog = new HIGMessageDialog( renameEntryDialog, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Rename error", errorMsg); dialog.Run(); dialog.Destroy(); } renameEntryDialog.HideAll(); }
public static void DisplaySambaSIDWarning(Gtk.Window parent) { string msg = Mono.Unix.Catalog.GetString( "LAT could not determine your Samba System ID (SID). If you " + "haven't configured your directory for Samba yet, select " + "'Populate directory for samba' from the Server menu"); HIGMessageDialog dialog = new HIGMessageDialog( parent, 0, Gtk.MessageType.Warning, Gtk.ButtonsType.Ok, "Unable to enable Samba support", msg); dialog.Run(); dialog.Destroy(); }
public void missingAlert(string[] missing) { string msg = String.Format ( Mono.Unix.Catalog.GetString ("You must provide values for the following attributes:\n\n")); foreach (string m in missing) msg += String.Format ("{0}\n", m); HIGMessageDialog dialog = new HIGMessageDialog ( viewDialog, 0, Gtk.MessageType.Warning, Gtk.ButtonsType.Ok, "Attributes missing", msg); dialog.Run (); dialog.Destroy (); }
public static bool DeleteEntry(Connection conn, string[] dn) { string msg = String.Format( Mono.Unix.Catalog.GetString( "Are you sure you want to delete the selected entries?")); string errorMsg = Mono.Unix.Catalog.GetString( "Unable to delete the following entries:\n"); if (!Util.AskYesNo(null, msg)) { return(false); } bool allGood = true; foreach (string d in dn) { allGood = deleteEntry(conn, d); if (!allGood) { errorMsg += d; } } if (!allGood) { HIGMessageDialog dialog = new HIGMessageDialog( null, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Delete error", errorMsg); dialog.Run(); dialog.Destroy(); } return(allGood); }
void OnEmailActivate(object o, EventArgs args) { string url = GetSelectedAttribute("mail"); if (url == null || url == "") { string msg = Mono.Unix.Catalog.GetString( "Invalid or empty email address"); HIGMessageDialog dialog = new HIGMessageDialog( parentWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Email error", msg); dialog.Run(); dialog.Destroy(); return; } try { Gnome.Url.Show("mailto:" + url); } catch (Exception e) { string errorMsg = Mono.Unix.Catalog.GetString("Unable to send mail to: ") + url; errorMsg += "\nError: " + e.Message; HIGMessageDialog dialog = new HIGMessageDialog( parentWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Email error", errorMsg); dialog.Run(); dialog.Destroy(); } }
public static void ExportData(Connection conn, Gtk.Window parent, string dn) { FileChooserDialog fcd = new FileChooserDialog( Mono.Unix.Catalog.GetString("Save LDIF export as"), Gtk.Stock.Save, parent, FileChooserAction.Save); fcd.AddButton(Gtk.Stock.Cancel, ResponseType.Cancel); fcd.AddButton(Gtk.Stock.Save, ResponseType.Ok); fcd.SelectMultiple = false; ResponseType response = (ResponseType)fcd.Run(); if (response == ResponseType.Ok) { string data = export(conn, dn); try { using (StreamWriter sw = new StreamWriter(fcd.Filename)) { sw.Write(data); } } catch (Exception e) { Log.Debug(e); HIGMessageDialog dialog = new HIGMessageDialog( parent, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Export error", e.Message); dialog.Run(); dialog.Destroy(); } } fcd.Destroy(); }
public void missingAlert(string[] missing) { string msg = String.Format( Mono.Unix.Catalog.GetString("You must provide values for the following attributes:\n\n")); foreach (string m in missing) { msg += String.Format("{0}\n", m); } HIGMessageDialog dialog = new HIGMessageDialog( viewDialog, 0, Gtk.MessageType.Warning, Gtk.ButtonsType.Ok, "Attributes missing", msg); dialog.Run(); dialog.Destroy(); }
void WriteBytesToFile(string fileName, byte[] fileBytes) { try { FileStream fs = File.OpenWrite(fileName); fs.Write(fileBytes, 0, fileBytes.Length); fs.Close(); } catch (Exception e) { Log.Debug(e); HIGMessageDialog dialog = new HIGMessageDialog( null, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Save binary attribute error", e.Message); dialog.Run(); dialog.Destroy(); } }
public void OnHelpContentsActivate(object o, EventArgs args) { try { Gnome.Help.DisplayDesktopOnScreen(program, Defines.PACKAGE, "lat.xml", null, Gdk.Screen.Default); } catch (Exception e) { HIGMessageDialog dialog = new HIGMessageDialog( mainWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Help error", e.Message); dialog.Run(); dialog.Destroy(); } }
public static void ImportData(Connection conn, Gtk.Window parent, string data) { int numImported = 0; string msg = null; LDIF ldif = new LDIF(conn); numImported = ldif.Import(data); msg = String.Format( Mono.Unix.Catalog.GetString("Imported {0} entries."), numImported); if (numImported > 0) { HIGMessageDialog dialog = new HIGMessageDialog( parent, 0, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, "Import entries", msg); dialog.Run(); dialog.Destroy(); } else { HIGMessageDialog dialog = new HIGMessageDialog( parent, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Import error", msg); dialog.Run(); dialog.Destroy(); } }
void InsertAttribute() { string attrName; TreeModel model; TreeIter iter; if (!tv.Selection.GetSelected(out model, out iter)) { return; } attrName = (string)store.GetValue(iter, 0); if (attrName == null) { return; } SchemaParser sp = conn.Data.GetAttributeTypeSchema(attrName); if (!sp.Single) { TreeIter newRow = store.InsertAfter(iter); store.SetValue(newRow, 0, attrName); applyButton.Sensitive = true; } else { HIGMessageDialog dialog = new HIGMessageDialog( null, 0, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, "Unable to insert value", "Multiple values not supported by this attribute"); dialog.Run(); dialog.Destroy(); } }
void OnNetworkStateChanged(object o, NetworkStateChangedArgs args) { if (args.Connected) { mainWindow.Sensitive = true; } else { HIGMessageDialog dialog = new HIGMessageDialog( mainWindow, 0, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, "Network disconnected", "The network is down. LAT will disable itself until it comes back up"); dialog.Run(); dialog.Destroy(); mainWindow.Sensitive = false; } }
static void import(Connection conn, Gtk.Window parent, Uri uri) { int numImported = 0; LDIF ldif = new LDIF(conn); numImported = ldif.Import(uri); string msg = String.Format( Mono.Unix.Catalog.GetString("Imported {0} entries\nfrom {1}."), numImported, uri.ToString()); if (numImported > 0) { HIGMessageDialog dialog = new HIGMessageDialog( parent, 0, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, "Import entries", msg); dialog.Run(); dialog.Destroy(); } else { HIGMessageDialog dialog = new HIGMessageDialog( parent, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Import error", msg); dialog.Run(); dialog.Destroy(); } }
bool IsUIDAvailable() { if (!Util.CheckUID(conn, Convert.ToInt32(uidSpinButton.Value))) { string msg = Mono.Unix.Catalog.GetString( "The UID you have selected is already in use!"); HIGMessageDialog dialog = new HIGMessageDialog( newUserDialog, 0, Gtk.MessageType.Warning, Gtk.ButtonsType.Ok, "User error", msg); dialog.Run(); dialog.Destroy(); return(false); } return(true); }
bool IsPasswordEmpty() { if (passwordEntry.Text == "" || passwordEntry.Text == null) { string msg = Mono.Unix.Catalog.GetString( "You must set a password for the new user"); HIGMessageDialog dialog = new HIGMessageDialog( newUserDialog, 0, Gtk.MessageType.Warning, Gtk.ButtonsType.Ok, "User error", msg); dialog.Run(); dialog.Destroy(); return(true); } return(false); }
public void OnHelpClicked(object o, EventArgs args) { try { gettingHelp = true; Gnome.Help.DisplayDesktopOnScreen(program, Defines.PACKAGE, "lat.xml", "lat-preferences", Gdk.Screen.Default); } catch (Exception e) { HIGMessageDialog dialog = new HIGMessageDialog( null, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Help error", e.Message); dialog.Run(); dialog.Destroy(); } }
byte[] ReadFileBytes(string fileName) { List <byte> fileBytes = new List <byte> (); try { FileStream fs = File.OpenRead(fileName); byte[] buf = new byte[4096]; int ret = 0; do { ret = fs.Read(buf, 0, buf.Length); for (int i = 0; i < ret; i++) { fileBytes.Add(buf[i]); } } while (ret != 0); fs.Close(); } catch (Exception e) { Log.Debug(e); HIGMessageDialog dialog = new HIGMessageDialog( null, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Add binary value error", e.Message); dialog.Run(); dialog.Destroy(); } return(fileBytes.ToArray()); }
public static bool DeleteEntry(Connection conn, string dn) { string msg = String.Format("{0}\n{1}", Mono.Unix.Catalog.GetString( "Are you sure you want to delete"), dn); bool retVal = false; if (Util.AskYesNo(null, msg)) { try { conn.Data.Delete(dn); retVal = true; } catch (Exception e) { string errorMsg = Mono.Unix.Catalog.GetString( "Unable to delete entry ") + dn; errorMsg += "\nError: " + e.Message; HIGMessageDialog dialog = new HIGMessageDialog( null, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Delete entries", errorMsg); dialog.Run(); dialog.Destroy(); } } return(retVal); }
void InsertAttribute() { string attrName; TreeModel model; TreeIter iter; if (!tv.Selection.GetSelected (out model, out iter)) return; attrName = (string) store.GetValue (iter, 0); if (attrName == null) return; SchemaParser sp = conn.Data.GetAttributeTypeSchema (attrName); if (!sp.Single) { TreeIter newRow = store.InsertAfter (iter); store.SetValue (newRow, 0, attrName); applyButton.Sensitive = true; } else { HIGMessageDialog dialog = new HIGMessageDialog ( null, 0, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, "Unable to insert value", "Multiple values not supported by this attribute"); dialog.Run (); dialog.Destroy (); } }
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 (); } }
public static bool ModifyEntry(Connection conn, string dn, LdapModification[] modList) { if (modList.Length == 0) { Log.Debug ("No modifications to make to entry {0}", dn); return false; } try { conn.Data.Modify (dn, modList); Log.Debug ("Successfully modified entry {0}", dn); return true; } catch (Exception e) { string errorMsg = Mono.Unix.Catalog.GetString ("Unable to modify entry ") + dn; errorMsg += "\nError: " + e.Message; HIGMessageDialog dialog = new HIGMessageDialog ( null, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Modify entry", errorMsg); dialog.Run (); dialog.Destroy (); return false; } }
static void import(Connection conn, Gtk.Window parent, Uri uri) { int numImported = 0; LDIF ldif = new LDIF (conn); numImported = ldif.Import (uri); string msg = String.Format ( Mono.Unix.Catalog.GetString ("Imported {0} entries\nfrom {1}."), numImported, uri.ToString()); if (numImported > 0) { HIGMessageDialog dialog = new HIGMessageDialog ( parent, 0, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, "Import entries", msg); dialog.Run (); dialog.Destroy (); } else { HIGMessageDialog dialog = new HIGMessageDialog ( parent, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Import error", msg); dialog.Run (); dialog.Destroy (); } }
byte[] ReadFileBytes(string fileName) { List<byte> fileBytes = new List<byte> (); try { FileStream fs = File.OpenRead (fileName); byte[] buf = new byte[4096]; int ret = 0; do { ret = fs.Read (buf, 0, buf.Length); for (int i = 0; i < ret; i++) fileBytes.Add (buf[i]); } while (ret != 0); fs.Close (); } catch (Exception e) { Log.Debug (e); HIGMessageDialog dialog = new HIGMessageDialog ( null, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Add binary value error", e.Message); dialog.Run (); dialog.Destroy (); } return fileBytes.ToArray(); }
void OnEmailActivate(object o, EventArgs args) { string url = GetSelectedAttribute ("mail"); if (url == null || url == "") { string msg = Mono.Unix.Catalog.GetString ( "Invalid or empty email address"); HIGMessageDialog dialog = new HIGMessageDialog ( parentWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Email error", msg); dialog.Run (); dialog.Destroy (); return; } try { Gnome.Url.Show ("mailto:" + url); } catch (Exception e) { string errorMsg = Mono.Unix.Catalog.GetString ("Unable to send mail to: ") + url; errorMsg += "\nError: " + e.Message; HIGMessageDialog dialog = new HIGMessageDialog ( parentWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Email error", errorMsg); dialog.Run (); dialog.Destroy (); } }
bool IsUserNameAvailable() { if (!Util.CheckUserName (conn, usernameEntry.Text)) { string format = Mono.Unix.Catalog.GetString ( "A user with the username '{0}' already exists!"); string msg = String.Format (format, usernameEntry.Text); HIGMessageDialog dialog = new HIGMessageDialog ( newUserDialog, 0, Gtk.MessageType.Warning, Gtk.ButtonsType.Ok, "User error", msg); dialog.Run (); dialog.Destroy (); return false; } return true; }
void OnRowActivated(object o, RowActivatedArgs args) { TreePath path = args.Path; TreeIter iter; if (this.dataStore.GetIter (out iter, path)) { string dn = (string) this.dataStore.GetValue (iter, dnColumn); try { viewPlugin.OnEditEntry (conn, conn.Data.GetEntry (dn)); } catch (Exception e) { Log.Debug (e); string msg = Mono.Unix.Catalog.GetString ("Unable to edit entry"); HIGMessageDialog dialog = new HIGMessageDialog ( parentWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Error", msg); dialog.Run (); dialog.Destroy (); } } }
public static bool AddEntry(Connection conn, LdapEntry entry) { try { conn.Data.Add (entry); return true; } catch (Exception e) { string errorMsg = Mono.Unix.Catalog.GetString ("Unable to add entry ") + entry.DN; errorMsg += "\nError: " + e.Message; Log.Debug (e); HIGMessageDialog dialog = new HIGMessageDialog ( null, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Add error", errorMsg); dialog.Run (); dialog.Destroy (); return false; } }
public static bool DeleteEntry(Connection conn, string[] dn) { string msg = String.Format ( Mono.Unix.Catalog.GetString ( "Are you sure you want to delete the selected entries?")); string errorMsg = Mono.Unix.Catalog.GetString ( "Unable to delete the following entries:\n"); if (!Util.AskYesNo (null, msg)) return false; bool allGood = true; foreach (string d in dn) { allGood = deleteEntry (conn, d); if (!allGood) errorMsg += d; } if (!allGood) { HIGMessageDialog dialog = new HIGMessageDialog ( null, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Delete error", errorMsg); dialog.Run (); dialog.Destroy (); } return allGood; }
public void OnHelpClicked(object o, EventArgs args) { try { gettingHelp = true; Gnome.Help.DisplayDesktopOnScreen (program, Defines.PACKAGE, "lat.xml", "lat-preferences", Gdk.Screen.Default); } catch (Exception e) { HIGMessageDialog dialog = new HIGMessageDialog ( null, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Help error", e.Message); dialog.Run (); dialog.Destroy (); } }
public void OnOkClicked(object o, EventArgs args) { string oldDN = oldNameEntry.Text; string newDN = newNameEntry.Text; bool saveOld = saveOldNameCheckButton.Active; try { conn.Data.Rename (oldDN, newDN, saveOld); string msg = String.Format ( Mono.Unix.Catalog.GetString ( "Entry {0} has been renamed to {1}."), oldDN, newDN); HIGMessageDialog dialog = new HIGMessageDialog ( renameEntryDialog, 0, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, "Entry renamed", msg); dialog.Run (); dialog.Destroy (); renameHappened = true; } catch (Exception e) { string errorMsg = Mono.Unix.Catalog.GetString ("Unable to rename entry ") + oldDN; errorMsg += "\nError: " + e.Message; HIGMessageDialog dialog = new HIGMessageDialog ( renameEntryDialog, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Rename error", errorMsg); dialog.Run (); dialog.Destroy (); } renameEntryDialog.HideAll (); }
public void Populate() { if (viewPlugin.SearchBase == null) viewPlugin.SearchBase = conn.DirectoryRoot; try { LdapEntry[] data = conn.Data.Search (conn.DirectoryRoot, viewPlugin.Filter); Log.Debug ("InsertData()\n\tbase: [{0}]\n\tfilter: [{1}]\n\tnumResults: [{2}]", viewPlugin.SearchBase, viewPlugin.Filter, data.Length); string msg = string.Format (Mono.Unix.Catalog.GetString ("Found {0} entries"), data.Length); Global.Window.WriteStatusMessage (msg); DoInsert (data, viewPlugin.ColumnAttributes); } catch (Exception e) { HIGMessageDialog dialog = new HIGMessageDialog ( parentWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Connection error", e.Message); dialog.Run (); dialog.Destroy (); } }
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); }
bool IsPasswordEmpty() { if (passwordEntry.Text == "" || passwordEntry.Text == null) { string msg = Mono.Unix.Catalog.GetString ( "You must set a password for the new user"); HIGMessageDialog dialog = new HIGMessageDialog ( newUserDialog, 0, Gtk.MessageType.Warning, Gtk.ButtonsType.Ok, "User error", msg); dialog.Run (); dialog.Destroy (); return true; } return false; }
void toggleSambaWidgets(bool state) { if (state && firstTimeSamba) { string msg = Mono.Unix.Catalog.GetString ( "You must reset the password for this account in order to set a samba password."); HIGMessageDialog dialog = new HIGMessageDialog ( editUserDialog, 0, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, "Setting a samba password", msg); dialog.Run (); dialog.Destroy (); } smbLoginScriptEntry.Sensitive = state; smbProfilePathEntry.Sensitive = state; smbHomePathEntry.Sensitive = state; smbHomeDriveEntry.Sensitive = state; smbExpireEntry.Sensitive = state; smbCanChangePwdEntry.Sensitive = state; smbMustChangePwdEntry.Sensitive = state; smbSetExpireButton.Sensitive = state; smbSetCanButton.Sensitive = state; smbSetMustButton.Sensitive = state; }
void WriteBytesToFile(string fileName, byte[] fileBytes) { try { FileStream fs = File.OpenWrite (fileName); fs.Write (fileBytes, 0, fileBytes.Length); fs.Close (); } catch (Exception e) { Log.Debug (e); HIGMessageDialog dialog = new HIGMessageDialog ( null, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Save binary attribute error", e.Message); dialog.Run (); dialog.Destroy (); } }
void modifyGroup(LdapEntry groupEntry, LdapModification[] mods) { if (groupEntry == null) return; try { conn.Data.Modify (groupEntry.DN, mods); } catch (Exception e) { string errorMsg = Mono.Unix.Catalog.GetString ("Unable to modify group ") + groupEntry.DN; errorMsg += "\nError: " + e.Message; HIGMessageDialog dialog = new HIGMessageDialog ( editUserDialog, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Error", errorMsg); dialog.Run (); dialog.Destroy (); } }
public void OnEditActivate(object o, EventArgs args) { TreeModel model; if (this.Selection == null) return; TreePath[] tp = this.Selection.GetSelectedRows (out model); foreach (TreePath path in tp) { try { LdapEntry le = conn.Data.GetEntry (GetDN(path)); viewPlugin.OnEditEntry (conn, le); Populate (); } catch (Exception e) { Log.Debug (e); string msg = Mono.Unix.Catalog.GetString ("Unable to edit entry"); HIGMessageDialog dialog = new HIGMessageDialog ( parentWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Error", msg); dialog.Run (); dialog.Destroy (); } } }
bool IsUIDAvailable() { if (!Util.CheckUID (conn, Convert.ToInt32 (uidSpinButton.Value))) { string msg = Mono.Unix.Catalog.GetString ( "The UID you have selected is already in use!"); HIGMessageDialog dialog = new HIGMessageDialog ( newUserDialog, 0, Gtk.MessageType.Warning, Gtk.ButtonsType.Ok, "User error", msg); dialog.Run (); dialog.Destroy (); return false; } return true; }
private void Relogin() { try { if (useSSLCheckButton.Active) conn.Settings.Encryption = EncryptionType.SSL; if (conn.Settings.Encryption == EncryptionType.TLS) conn.StartTLS (); conn.Bind (userEntry.Text, passEntry.Text); } catch (Exception e) { string errorMsg = Mono.Unix.Catalog.GetString ("Unable to re-login"); errorMsg += "\nError: " + e.Message; HIGMessageDialog dialog = new HIGMessageDialog ( loginDialog, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Login error", errorMsg); dialog.Run (); dialog.Destroy (); } }
void OnRowExpanded(object o, RowExpandedArgs args) { string name = null; name = (string) schemaStore.GetValue (args.Iter, (int)TreeCols.ObjectName); if (name == "Servers") return; TreeIter child; schemaStore.IterChildren (out child, args.Iter); string childName = (string) schemaStore.GetValue (child, (int)TreeCols.ObjectName); if (childName != "") return; schemaStore.Remove (ref child); Log.Debug ("Row expanded {0}", name); string serverName = FindServerName (args.Iter, schemaStore); Connection conn = Global.Connections [serverName]; try { Gdk.Pixbuf pb = Gdk.Pixbuf.LoadFromResource ("text-x-generic.png"); string[] kids = GetChildren (name, conn); foreach (string s in kids) { schemaStore.AppendValues (args.Iter, pb, s); } TreePath path = schemaStore.GetPath (args.Iter); this.ExpandRow (path, false); } catch (Exception e) { schemaStore.AppendValues (args.Iter, null, ""); Log.Debug (e); string msg = Mono.Unix.Catalog.GetString ( "Unable to read schema information from server"); HIGMessageDialog dialog = new HIGMessageDialog ( parentWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Server error", msg); dialog.Run (); dialog.Destroy (); } }
public static void ImportData(Connection conn, Gtk.Window parent, string data) { int numImported = 0; string msg = null; LDIF ldif = new LDIF (conn); numImported = ldif.Import (data); msg = String.Format ( Mono.Unix.Catalog.GetString ("Imported {0} entries."), numImported); if (numImported > 0) { HIGMessageDialog dialog = new HIGMessageDialog ( parent, 0, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, "Import entries", msg); dialog.Run (); dialog.Destroy (); } else { HIGMessageDialog dialog = new HIGMessageDialog ( parent, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Import error", msg); dialog.Run (); dialog.Destroy (); } }
public static bool DeleteEntry(Connection conn, string dn) { string msg = String.Format ("{0}\n{1}", Mono.Unix.Catalog.GetString ( "Are you sure you want to delete"), dn); bool retVal = false; if (Util.AskYesNo (null, msg)) { try { conn.Data.Delete (dn); retVal = true; } catch (Exception e) { string errorMsg = Mono.Unix.Catalog.GetString ( "Unable to delete entry ") + dn; errorMsg += "\nError: " + e.Message; HIGMessageDialog dialog = new HIGMessageDialog ( null, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Delete entries", errorMsg); dialog.Run (); dialog.Destroy (); } } return retVal; }
void DoInsert(LdapEntry[] objs, string[] attributes) { try { if (this.dataStore != null) this.dataStore.Clear (); foreach (LdapEntry le in objs) { string[] values = conn.Data.GetAttributeValuesFromEntry (le, attributes); string[] newvalues = new string [values.Length + 1]; values.CopyTo (newvalues, 0); newvalues [values.Length] = le.DN; this.dataStore.AppendValues (newvalues); } } catch { string msg = Mono.Unix.Catalog.GetString ( "Unable to read data from server"); HIGMessageDialog dialog = new HIGMessageDialog ( parentWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Network error", msg); dialog.Run (); dialog.Destroy (); } }
public static void DisplaySambaSIDWarning(Gtk.Window parent) { string msg = Mono.Unix.Catalog.GetString ( "LAT could not determine your Samba System ID (SID). If you " + "haven't configured your directory for Samba yet, select " + "'Populate directory for samba' from the Server menu"); HIGMessageDialog dialog = new HIGMessageDialog ( parent, 0, Gtk.MessageType.Warning, Gtk.ButtonsType.Ok, "Unable to enable Samba support", msg); dialog.Run (); dialog.Destroy (); }
public static void ExportData(Connection conn, Gtk.Window parent, string dn) { FileChooserDialog fcd = new FileChooserDialog ( Mono.Unix.Catalog.GetString ("Save LDIF export as"), Gtk.Stock.Save, parent, FileChooserAction.Save); fcd.AddButton (Gtk.Stock.Cancel, ResponseType.Cancel); fcd.AddButton (Gtk.Stock.Save, ResponseType.Ok); fcd.SelectMultiple = false; ResponseType response = (ResponseType) fcd.Run(); if (response == ResponseType.Ok) { string data = export (conn, dn); try { using (StreamWriter sw = new StreamWriter(fcd.Filename)) { sw.Write (data); } } catch (Exception e) { Log.Debug (e); HIGMessageDialog dialog = new HIGMessageDialog ( parent, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Export error", e.Message); dialog.Run (); dialog.Destroy (); } } fcd.Destroy(); }
void OnWWWActivate(object o, EventArgs args) { string url = GetSelectedAttribute ("wWWHomePage"); try { Gnome.Url.Show (url); } catch (Exception e) { string errorMsg = Mono.Unix.Catalog.GetString ("Unable to open page: ") + url; errorMsg += "\nError: " + e.Message; HIGMessageDialog dialog = new HIGMessageDialog ( parentWindow, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Network error", errorMsg); dialog.Run (); dialog.Destroy (); } }
public void OnOkClicked(object o, EventArgs args) { if (passwordEntry.Text != reenterEntry.Text) { string msg = Mono.Unix.Catalog.GetString ("Password don't match"); HIGMessageDialog dialog = new HIGMessageDialog ( passwordDialog, 0, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, "Password error", msg); dialog.Run (); dialog.Destroy (); passwordsDontMatch = true; return; } GeneratePassword (); }