Solved

C# Virtual machine with Windows Server R2 Active Directory

Posted on 2014-12-10
10
270 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 35

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 78

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
 

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 78

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
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.

 
LVL 35

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 35

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
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 …

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now