Solved

C# Virtual machine with Windows Server R2 Active Directory

Posted on 2014-12-10
10
332 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 37

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 82

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 71

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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

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 82

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 37

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 37

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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

A hard and fast method for reducing Active Directory Administrators members.
Microsoft Office 365 is a subscriptions based service which includes services like Exchange Online and Skype for business Online. These services integrate with Microsoft's online version of Active Directory called Azure Active Directory.
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Suggested Courses

623 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