Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. urgent help please

urgent help please

Scheduled Pinned Locked Moved C#
csharpsysadminwindows-adminhelpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    amarsumanth
    wrote on last edited by
    #1

    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

    S D K 3 Replies Last reply
    0
    • A amarsumanth

      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

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • A amarsumanth

        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

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • A amarsumanth

          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

          K Offline
          K Offline
          ksanju1000
          wrote on last edited by
          #4

          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);

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups