Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C# Virtual machine with Windows Server R2 Active Directory

Posted on 2014-12-10
10
Medium Priority
?
356 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 83

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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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 83

Accepted Solution

by:
David Johnson, CD, MVP earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises 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 to another domain controller. Log onto the new domain controller with a user account t…
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.
Suggested Courses

661 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