- Upvotes Received
- 4
- Posts with Upvotes
- 3
- Upvoting Members
- 3
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
22 Posted Topics
Re: You can add data that is returned from a reader the same way you would programmatically add items to a combobox (combobox1.Items.Add(*Object to add to combobox*); Here is a sample of code that I did a while ago, this reads all of the Columns on a particular table and adds … | |
Re: NFurman, Looking at your connection string I am unable to determine what credentials you are using, but the credentials in the connection string should be the SQL server credentials, not the client logon credentials. | |
Re: When you use WMI to query running process you can use a WHERE clause when there is an available attribute, unfortunately Owner is not one of the attributes, there may be a way to resolve the process ID or Session ID to a specific Owner, possibly? At any rate, Here … | |
Re: Skinder, you can use WMI to query printer information (Win32_Printer). Below is some sample code that I wrote a while ago, this will retrieve every printer mapped to your computer and give you all available details about it. Create a windows form application and add a Button and TreeView and … | |
Re: I am not sure if this will help, but I wrote an Active Directory tool that needed to run on administrator credentials, here is the code. Hope this helps or at least points you in the right direction. [code] using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using System.Runtime.InteropServices; using … | |
Re: Here is a method that uses the FileStream object, but you can also use the StreamWriter object to write data to a text file. The code below creates the file if it doesn't exist, then writes the data to the text file. If the file already exist you will use … | |
Re: Aliiya, You can add values from directly to a database using the following example, However, I recommend creating a stored procedure instead of using variables within your string, I just did it this way as an example: [code] string _InsertRow = "INSERT INTO `"+ DatabaseName +"`.`" + TableName +"` (`FirstName` … | |
Re: List<string> Directories = new List<string>(System.IO.Directory.GetDirectories("C:\\")); List<string> Files = new List<string>(System.IO.Directory.GetFiles("C:\\")); Not sure if this helps but I was writing some code for a TreeView and created list<>, one for the directories and one for the files. | |
Does anyone know how to get the adspath attribute value to a better looking string. Active Directory returns the following: "LDAP://contoso.com/CN=Sanch01R,OU=Managers,OU=Users,OU=InfoTech,DC=contoso,DC=com"; I would like it to read: contoso.com/infotech/users/managers/sanch01r The IndexOf and Substring methods do not work consistently as we never know how many OU's would be returned, any ideas would … | |
Re: Here is an example that I put together. I wrote a Remove Duplicate method that accepts a List as an overload. It will remove the remove the duplicates and send it back to its caller. Here goes. [code] static void Main(string[] args) { try { List<string> Letters = new List<string>(); … | |
Re: Found an old code snippet, Here goes. [code] static void Main(string[] args) { string line; try { StreamReader sr = new StreamReader(new FileStream("C:\\Techdata.txt", FileMode.Open)); line = sr.ReadLine(); while (line != null) { Console.WriteLine(line); line = sr.ReadLine(); } sr.Dispose(); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadKey(); } [/code] | |
Hey guys, I am writing an Active Directory Tool and I created a Dictionary<> that iterates through all of the available attributes from the LDAP server. The Keys are the names of the attributes (displayname, samaccountname, gn, sn, etc), the TValues are the associated values to the keys. I am … | |
Re: Found an old example. I am not sure if this will help out entirely but it should convey the general idea. You can retrieve the selected item value and /or the checklisted item alone, I created a form with a checklistbox, and two listboxes titled listbox1 and listbox2. Listbox1 one … | |
Re: Just in case, here is a method to read from a CSV or delimiter. It returns data to its caller. [code] static void Main(string[] args) { List<string> columns; List<Dictionary<string, string>> myData = GetData(out columns); foreach (string column in columns) { Console.Write("{0,-20}", column); } Console.WriteLine(); foreach (Dictionary<string, string> row in myData) … | |
Re: Here is some code that I wrote a while back, it populates a TreeView with the directories and files from the path in the textbox. You will need to add a TreeView control to your form, a button, and a textbox for the path. [code] private void button1_Click(object sender, EventArgs … | |
Hey guys, I am needing to find out the expiration date of a users password using the LDAP attribute "pwdlastset", I am able to retrieve the date of the last password reset. The password expiration date should be exactly 90 days from the "pwdlastset" value. For some reason I am … | |
Hey guys, I am writing an Active Directory Tool that allows my team to read data without having to access Active Directory through a remote desktop session. I am not too familiar with the TreeView control and I was wondering if there was a way to add the Active Directory … | |
Re: The example below will retrieve the value of a checkbox and display it in a messagebox on a button click event. [code] if (checkBox1.Checked) { MessageBox.Show(checkBox1.Text.ToString()); } [/code] | |
Re: From the form load method, you can disable the button. button1.Enabled = false; On the click event enable the button. button1.Enabled = true; | |
Re: You can create a method that uses a ternary operator that determines if a null value exist, if it does then send back an empty string or "----" rather than a null value. logic: Does DataGridView(columnXX) have a null value? If Yes, send back an empty string "" or else … | |
Re: You can create your new DirectoryEntry object on the fly and pass it to the search object. [code] DirectorySearcher search = new DirectorySearcher(new DirectoryEntry("LDAP://servername.net", "administrator", "password123$")); [/code] | |
Re: You can use the IDictionary interface. All you have to do is pass the field (AD attribute field) to Dictionary and pass the ResultProperty or The value from the cell to it as its key, then iterate through it. [code] private Dictionary<string, ResultProperty>[] GetDataReader(string Fields, string Table, string Conditions) [/code] |
The End.