Solved

C# Virtual machine with Windows Server R2 Active Directory

Posted on 2014-12-10
10
293 Views
Last Modified: 2014-12-13
I've set up a virtual machine using Hyper-V manager. What I want to do is be able to connect to the active directory from the host machine. Can any one tell me how to do this? I need to be able to get a list of users using C#

I can ping the server, but can not access active directory, I've tried adding my laptop to the domain but it can find the domain.
0
Comment
Question by:Webfort
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 36

Expert Comment

by:Mahesh
ID: 40493177
Where is your active directory server?

It is on VM or it is outside hyper-v server?
If its outside hyper-v server,
then U need to create external switch pointing to production adapter on hyper-v server and bind your BM to this virtual network
This will enable VM external access to production network

Then ensure that DC ip is set as DNS server IP on VM tcp/ip and join that machine to domain and then try
0
 
LVL 79

Expert Comment

by:David Johnson, CD, MVP
ID: 40493186
change your dns settings and add the ip address of the virtual domain controller to your dns settings. Now you should be able to join the domain
0
 
LVL 70

Expert Comment

by:Chris Dent
ID: 40493300
If you're attempting to connect to AD you should be able to do so using the IP of the host:
DirectoryEntry de as new DirectoryEntry("LDAP://1.2.3.4", "username", "password");

Open in new window

If you're already authenticated against the domain you can omit the username and password, but if that were the case you could use serverless binding anyway:
DirectoryEntry de as new DirectoryEntry();

Open in new window

In either case you can pass the authenticated DirectoryEntry to the DirectorySearcher to gather a list of users in the domain.

Chris
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:Webfort
ID: 40493332
Thanks for your comments.
This is what I have:
Laptop with Windows 8.1 installed. I've installed Hyper-V and created a Windows 2008 R2 Server and installed the following (please see attached Shot1.png).
Shot 2 is what I get when I ping the server.

Shot3 are the settings of the Virtual server. External Virtual Switch selected is the switch I created.

If you need any more information please let me know. I don't really have any experience of configuring servers in this way.

It would be nice to be able to connect to Active Directory using the domain name only.

Thanks in advance
0
 
LVL 79

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
ID: 40493359
ping (icmp) is normally disabled in the firewall you have to add it. no attachments?
Add the virtual domain name to your hosts file or change your network adapter dns
0
 
LVL 36

Expert Comment

by:Mahesh
ID: 40493466
screen shot is missing

Still you haven't answered my questions in 1st post
0
 

Author Comment

by:Webfort
ID: 40495625
Answers
Where is your active directory server? - On the Virtual Server

It is on VM or it is outside hyper-v server? On the VM

How do I do the following
Add the virtual domain name to your hosts file or change your network adapter dns
Shot1.zip
0
 
LVL 36

Expert Comment

by:Mahesh
ID: 40495831
remove IPv6 checkbox from domain controller virtual machine

Then try to ping DC Ip from Hyper-V host, if require disable DC firewall

If it able to ping, add DC IP on Hyper-V server network card as DNS and then try to ping DC with domain.com

If that works you can join hyper-v server to domain
In VM settings, ensure that VM automatic start action would be always start automatically, this will enable Hyper-V host to logon to domain
http://www.techrepublic.com/blog/data-center/configure-a-hyper-v-vm-for-automatic-startup/
0
 

Author Closing Comment

by:Webfort
ID: 40498055
By adding the ip address and the domain this worked. Thanks for all your help
0
 

Author Comment

by:Webfort
ID: 40498059
I have accepted a solution as I can now run the code, is it possible to get the host to join the domain? I've tried switching from workgroup to a domain but its says it cant contact it?
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question