dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: How to get local SMTP Server Domain names by using C# code

  1. #1
    Join Date
    Dec 2007
    Posts
    22

    How to get local SMTP Server Domain names by using C# code

    Hi,
    I have one problem with SMTP Domains. I want to know that what are the domains are there in local SMTP Server in IIS.(In IIS Default SMTP Virtual Server, in that Domains). I need C# code for this. Please help me on this.

    Thanks,

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    To get Domain use WMI or ADSI, both are accessible from .NET through the System.Management and System.DirectoryServices namespaces.

    To get the machine account domain for instance you can query the
    'Win32_ComputerSystem' WMI class like this:

    Code:
    SelectQuery query = new SelectQuery("Win32_ComputerSystem");
    using(ManagementObjectSearcher searcher = new
    ManagementObjectSearcher(query))
    {
    foreach (ManagementObject mo in searcher.Get()) {
         if((bool)mo["partofdomain"] != true)
            Console.WriteLine("Workgroup: {0} ",mo["workgroup"]);
         else
             Console.WriteLine("Domain: {0} ",mo["domain"]);
         }
    }

  3. #3
    Join Date
    Dec 2007
    Posts
    22
    Hi hack,
    Actually I do not want Default Domain. I want list of all domains which includes our created domain names also.

    Thanks,

Similar Threads

  1. find version & service packs
    By rperez in forum Database
    Replies: 5
    Last Post: 01-02-2009, 05:14 PM
  2. Replies: 3
    Last Post: 06-02-2006, 09:00 PM
  3. VS.Net and Code Behind
    By Chaitanya Marvici in forum ASP.NET
    Replies: 6
    Last Post: 07-21-2003, 09:15 AM
  4. .NET equals Efficiency
    By Kevin in forum .NET
    Replies: 150
    Last Post: 03-04-2002, 06:40 PM
  5. Remove exchange from a site
    By andriano in forum Enterprise
    Replies: 1
    Last Post: 10-02-2000, 03:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center