urgent help please
-
i need to obtain computer names and their ip addresses of a network (LAN). i.e i have to scan the network and obtain all computer names and ip addresses WITHOUT USING ACTIVE DIRECTORY. i m developing in C#. can anybody help me in this context please? Amar
-
i need to obtain computer names and their ip addresses of a network (LAN). i.e i have to scan the network and obtain all computer names and ip addresses WITHOUT USING ACTIVE DIRECTORY. i m developing in C#. can anybody help me in this context please? Amar
AFAIK, there is no API in .NET to do what you want. You can pinvoke and use the
NetServerEnum
API (Netapi32.dll) instead. Regards Senthil _____________________________ My Blog | My Articles | WinMacro -
i need to obtain computer names and their ip addresses of a network (LAN). i.e i have to scan the network and obtain all computer names and ip addresses WITHOUT USING ACTIVE DIRECTORY. i m developing in C#. can anybody help me in this context please? Amar
Ping each IP address in the range your looking for. If you get a response, then you can use a DNS lookup on that address to return the name associated with that address. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
i need to obtain computer names and their ip addresses of a network (LAN). i.e i have to scan the network and obtain all computer names and ip addresses WITHOUT USING ACTIVE DIRECTORY. i m developing in C#. can anybody help me in this context please? Amar
Hi I have some notes on this topic if you still getting problem pls tell me 5.7.6. Get current user name This sample presents two different approaches to getting current user information. Namespaces: using System; using System.Net; using System.Security.Principal; Code: static void Main(string[] args) { // get info about current user using Environment class Console.WriteLine(Environment.UserDomainName + @"\" + Environment.UserName); // -------------------------- // get current user from WindowsIdentity class WindowsIdentity user = WindowsIdentity.GetCurrent(); // output current user name Console.WriteLine(user.Name.ToString()); } 5.7.7. Impersonate as another user using System; using System.Runtime.InteropServices; using System.Security.Principal; class ImpersonateUser { // this implementation doesn't handle GetLastError function to catch error messages, it should be implemented in standard application // mapping of Win32 function to logon under another account [DllImport("advapi32.dll", SetLastError = true)] public static extern bool LogonUser( String lpszUsername, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken); // this will duplicate access token based on current user's one [DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)] public extern static bool DuplicateToken( IntPtr ExistingTokenHandle, int SECURITY_IMPERSONATION_LEVEL, ref IntPtr DuplicateTokenHandle); [DllImport("kernel32.dll", CharSet = CharSet.Auto)] public extern static bool CloseHandle(IntPtr handle); static void Main(string[] args) { const int LOGON32_LOGON_INTERACTIVE = 2; const int LOGON32_PROVIDER_DEFAULT = 0; const int SecurityImpersonation = 2; // handle of access token of current user IntPtr token = IntPtr.Zero; // new token based on the old one IntPtr duplicateToken = IntPtr.Zero; // this method returns handle to access token of user we want to use to logon, user is check just in local database if (LogonUser("TestUser", ".", "Test1234]", LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref token)) { // token is duplicated according to the token of impersonated user if (DuplicateToken(token, SecurityImpersonation, ref duplicateToken)) { Console.WriteLine("Current user name: " + WindowsIdentity.GetCurrent().Name); // new identity is created WindowsIdentity newIdentity = new WindowsIdentity(duplicateToken);