473,320 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Get Server Domain

Using vbscript I can get the domain of a server by binging to the WinNT provider and then getting the ADsPath

Set comp = GetObject("WinNT://MyComputer"
sComputerAndDomain = comp.ADsPat

How do I do the same using c# and the .net framework

Thank
Richard Chown
Jul 21 '05 #1
2 1203
Following code works for me

using System.DirectoryServices
...
DirectoryEntry entry = new DirectoryEntry("WinNT://Server03a")
string domain = entry.Parent.Name
Console.WriteLine(domain)
...

Note in general System.DirectoryServices does not provide access to all the ADSI functionality, so you may need to resort to adding a reference to the COM ADSI library (activeds.tlb) - then you will have access to the functionality you are familiar with

Richard
Jul 21 '05 #2
Thanks, works for me too. Exactly what I was looking for

----- richlm wrote: ----

Following code works for me

using System.DirectoryServices
..
DirectoryEntry entry = new DirectoryEntry("WinNT://Server03a")
string domain = entry.Parent.Name
Console.WriteLine(domain)
..

Note in general System.DirectoryServices does not provide access to all the ADSI functionality, so you may need to resort to adding a reference to the COM ADSI library (activeds.tlb) - then you will have access to the functionality you are familiar with

Richard
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Vaap | last post by:
I did lot of googling to see if I can solve the SQL server not found problem while trying to run ASP.Net community starter kit from an XP machine to Windows 2003 server hosting SQL server 2000...
3
by: Wysiwyg | last post by:
After a server created cookie is processed on the client I want it removed, cleared, or expired in the javascript block but have been unable to do this. If I set a cookie value in the server code...
34
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow...
1
by: eblackmo | last post by:
I have a test network consisting of four servers running windows 2003 server R2 SP2. I have set up a domain which functioned correctly for about a day and a half until the other servers decided they...
3
by: Kevinp | last post by:
I'm trying to get my program to connect to a SQL Server 2005 database over the internet. The remote computer is on another network and it's connected to our network through Windows VPN. I'm running...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.