0

I have been asked to write a small utility to copy users from an AD to another system.

I found this posting which looks perfect to get me going...

How can I get a list of users from active directory?

As I don't have an AD to work with, I went to my Azure portal and created one on there to test against...

Then, it looked like all I needed to do was insert my domain in this line....

using (var context = new PrincipalContext(ContextType.Domain, "yourdomain.com"))

My domain, as supplied by Azure is xxxx.onmicrosoft.com

but when I run the code, I keep getting

An unhandled exception of type 'System.DirectoryServices.AccountManagement.PrincipalServerDownException' occurred in System.DirectoryServices.AccountManagement.dll

Additional information: The server could not be contacted.

Can anyone see what I am missing please?

Community
  • 1
  • 1
Trevor Daniel
  • 3,785
  • 12
  • 53
  • 89
  • Have you created Windows Azure Active Directory (WAAD) or installed the AD on a Azure VM? – ramiramilu Jan 07 '14 at 11:48
  • @ramiramilu i've created a WAAD. – Trevor Daniel Jan 07 '14 at 11:55
  • 1
    You can query WAAD using its Graph API - http://blog.rytmis.net/2012/12/windows-azure-active-directory-querying.html. I doubt you cannot do with native C# DirectoryServices class. At present you have only REST API for these operations, unleass you create a Azure VM and install AD on it and then sync WAAD to it, then use DirectoryServices on local AD. – ramiramilu Jan 07 '14 at 11:57
  • i just want an AD for some testing. perhaps i should just create a Server2008 VM and open the LDAP ports? – Trevor Daniel Jan 07 '14 at 12:05
  • you can simply create a AD on Azure VM - http://www.windowsazure.com/en-us/manage/services/networking/active-directory-forest/ and use it – ramiramilu Jan 07 '14 at 12:07
  • if you still want to query WAAD, then check out this tutorial - http://yossidahan.wordpress.com/2013/11/28/role-based-authorisation-with-windows-azure-active-directory/ – ramiramilu Jan 07 '14 at 12:08

1 Answers1

0

i borrowed my mates old server and built a local server 2012 and joined the domain.

probably not everyone's answer. but worked for me.

(if i had more time i would have liked to get the azure domain working... im sure i built it right. just didn't work.

so that's my answer.

Trevor Daniel
  • 3,785
  • 12
  • 53
  • 89