|
Hi,
How would I go about finding a devices IP address given its hardware address?
I have a group of thin clients and they are given IP addresses by DHCP, I'm writing a little program to start a secure shell and that needs the clients IP address and all I have is the MAC.
Hope someone can help
Stephen
|
|
|
|
|
Your program runs on the client or the server?
What does "start a shell" mean?
|
|
|
|
|
The program will be run on a windows 2003 terminal server and will be used to issue commands to the thin clients that connect to the server. The server has a config file thinstation.hosts that contains the MAC address and name of each of the clients and I want to find the IP address of each of these clients which is assigned by dhcp. I'd like to do this without resorting to giving them all dhcp reservations and creating a new config file mapping these, which is quite possible but messy.
The dhcp server is a separate Windows 2003 server, I was thinking I may be able to lookup an IP address with a query this dhcp server (using WMI?). Or maybe as I know the name of the clients a query to DNS. Now before someone says just connect using the name, for some reason I can't. I think because the clients live in the .local domain and the server lives in the active directory domain.
A Secure Shell or SSH is a network protocol that allows data to be exchanged over a secure channel between two computers. I'm using Tamir.SharpSSH http://www.codeproject.com/cs/internet/sharpssh.asp and this works great when connect manually.
Hope this gives a little more info about what I'm looking for
Cheers, Stephen
|
|
|
|
|
r-mo wrote: Hope this gives a little more info about what I'm looking for
Well it's a start. I can't fathom why you wouldn't provide that information in your original post but whatever.
r-mo wrote: used to issue commands to the thin clients
"commands" is completely ambiguous so I still have no idea what your needs are. But since you do or might, I assume you have already eliminated using the Terminal Services API for your solution? Perhaps you could explain why the API does not provide a solution for you?
|
|
|
|
|
I think the WTSQuerySessionInformation function will do just what I need as it can retrieve the clients IP as well as a lot of other useful info I just need to figure out how to use it with C#.
Sorry for not including that info in my first post, I was thinking along the lines of querying dhcp for the ip rather than terminal services.
And the commands I'm issuing to the clients can't be done using the API afaik. They are running thinstation linux (http://thinstation.sourceforge.net) connecting with rdesktop. Commands issued will be things like shutting down the clients at the end of the day. Updating the thinstation image on the clients hard drive/flash memory etc...
Thanks for all your help
Stephen
|
|
|
|
|
r-mo wrote: I just need to figure out how to use it with C#.
You know about PInvoke yes? Also C++/CLI is a superior solution for managed development and greatly simplifies integration of native libraries.
r-mo wrote: Thanks for all your help
your welcome and good luck with your project.
|
|
|
|
|
I believe you can get the MAC/IP address table fromy our switch/router by using SNMP. I haven't actually done it, but I'm sure an existing SNMP library for C# is out there. Hope that helps get you in the right direction.
|
|
|
|
|
Good idea, I'll look into that, not really played with SNMP before. There's RARP too, that might work as well? all cisco switches if that makes a difference?
I would prefer to keep the app as non network specific as possible though that way other people who use thinstation may benefit from it
|
|
|
|
|
I'm a C++ programmer about 2 years. My question is not about to solve a specific trouble. I'm being scared with the crescent growing of languages like C# and Java. What I would like to know of anyone is the following: These languages will definitely substitute C++? In any kind of market. I've readed some news that game industry are thiking to adopt a unique hardware(something like a setupbox) and develop games to it. The programming language I think, will occur the same. If this hardware have an virtual machine inside it, java and C# are natural choices to develop games.
so, what do you think about that?
|
|
|
|
|
Alex Cutovoi wrote: I'm being scared
Of what?
Alex Cutovoi wrote: what do you think about that?
I don't know what to think, you didn't provide a link to this "news".
|
|
|
|
|
Alex Cutovoi wrote: My question is not about to solve a specific trouble.
Then you're posting in the wrong forum. This forum is for specific coding questions about C#
|
|
|
|
|
Alex Cutovoi wrote: These languages will definitely substitute C++?
In certain areas. For Line of business applications Java and C# have practically shut out C++ already.
In games there is now the XNA framework for C#. That is just for hobbiests, but I'm sure that commercial frameworks will be (or maybe already are) available.
|
|
|
|
|
You can use XNA and C# to make games for the 360 too. At least, thats what i was told...or thats what i think i was told...
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Hi,
In a TreeView/ListView Form a TreeNodeMouseClickEvent on a TreeView is showing the ListView items.
When loading the Form, it also must return the ListView items of the First Node (rootNode).
But the ListView items are only returned after selecting a Node.
Has anyone an idea how to load the the Listview Items of the First TreeView Node(rootNode)?
|
|
|
|
|
You mean like using the Forms OnLoad event?
|
|
|
|
|
Thanx man....you brought me on an idea and it worked...
|
|
|
|
|
Hello,
I am currently working on a windows app project that intend to add records to a ms sql server 2000 database. It consists only a single simple form which have a TextBox, a save button, a cancel button. Now, the task is simple how can I enter new record to the database by typing record data into the texbox and hitting the save button to save it?
thanks in advance.
PS: I don't want to use any special toolbox control or component. I just want to use my simple form controls with only add record ability.
|
|
|
|
|
sharpseer wrote: Now, the task is simple how can I enter new record to the database by typing record data into the texbox and hitting the save button to save it?
In code create a SqlConnection object, and a SqlCommand object. In the command object create your INSERT statement, or refer to the relevant stored procedure. Add the parameters to pass the data to the command.
Ensuring your connection is open, use ExecuteNonQuery() on the command. Finally closed the connection.
|
|
|
|
|
I get an Invalid Operation Exception error because the program is trying to make a cross-thread call to a listview object that was created by the main thread.
The basic operation of the program is that items can be added, removed, modified,and cleared for the listview component on the panel. If I want, I can start a timer. Meanwhile a 'listener' sits in another thread waiting for the time to elapse. On this elapsed timer event, it enters the OnTimerDoThis() event-handler. Within the event-handler, on the foreach line, the 'Invalid Operation Exception' error occurs only after an item is added to the listview, or if an item exists already. I have put a comment at the end of the line -> '//ERROR HAPPENS HERE' so that using Find will take you to that line. The purpose of the foreach is to search the listview items and indicate if it matches to a string constant.
I was able to create a delegate for a radio component and able to handle the same exception error, but need to do the same for the listview. Question is how do I get around the error?
FYI. I am not using the background watcher.
protected void OnTimerDoThis(Object source, ElapsedEventArgs e)
{
// immediatly disable timer after timeout interval reached
DisableTimer();
MessageBox.Show("Inside OnTimerDoThis asnyc event\n\nTimer Disabled\n\n" +
"Press OK to re-enable Timer");
foreach (ListViewItem item in lvData.Items) //ERROR HAPPENS HERE
{
//if (sWindowTitle.StartsWith(item.Text))
if (matchString.StartsWith(item.Text))
{
MessageBox.Show("Inside match string and asnyc event\n\nTimer Disabled\n\n" +
"Press OK to re-enable Timer");
}
}
EnableTimer();
}
Regards....
|
|
|
|
|
I am not sure I understood everything but ... aren't you trying to iterate through listview items with a thread while eventually modifying the same collection with another one (the main one) ?
|
|
|
|
|
Yes. The main thread allows the user to add, remove, modify, clear, the listview.
I have a button the allows the user to Start of Stop the timer. If I start the timer, and the timer has elapsed, it will search the items in the listview for a match in the async thread event-handler OnTimerDoThis().
This is mainly for me to understand why the error occurs and how to handle the error.
I plan on using something like this in the future with better functionality, but before going BIG, I need to understand the smaller stuff.
If you want I can forward the file for your review
thanks for the quick reply
|
|
|
|
|
cirkit1 wrote: Yes.
I strongly urge you to read some material about multi-threading and synchronization. I recommend the book Advanced Windows by Richter. I have also seen people recommend a web site tutorial on threading but I don't know the URL. I am sure you can find it using google. I think there are articles here on CodeProject as well.
|
|
|
|
|
Is it http://www.albahari.com/threading/ ?
|
|
|
|
|
I have searched a multitude of sites and so far nothing specific to listview and my particular problem, hence my posting. There is a lot out there though, I agree.
As an FYI, I was able to handle the same exception error regarding a radio control where I needed to change the boolean state of radio component from an async process, specifically when called from event-handler OnTimerDoThis(). I did this by following some examples for a textbox from MSDN. The following is portions of code to do this:
// create a delegate within the class
delegate void SetRadioCallback(bool Status);
private void SetRadio(bool status)
{
// InvokeRequired required compares the thread ID of the
// calling thread to the thread ID of the creating thread.
// If these threads are different, it returns true.
if (this.rdoTimerStatus.InvokeRequired)
{
// calling and creating thread are different
SetRadioCallback r = new SetRadioCallback(SetRadio);
this.Invoke(r, new object[] { status });
}
else
{
this.rdoTimerStatus.Checked = status;
}
}
// EnableTimer() is called from the main thread and async thread
// at different times, never at the same time
protected void EnableTimer()
{
m_Timer.Enabled = true;
// call SetRadio to determine which thread is calling and update
this.SetRadio(true);
}
Now, how do I do the same for a listview? I am not really changing anything in the listview. I just want it to search in the listview items for a match on the time elapsed event.
|
|
|
|
|
cirkit1 wrote: I have searched a multitude of sites and so far nothing specific to listview and my particular problem
That's why I posted what I did. In my opinion you don't want to try to learn about mult threading issues by being "specific" to using a listview. You seem resistant to my suggestion so I am not going to argue with you.
Have you found this MSDN Article[^]
|
|
|
|