views:

627

answers:

2

Is it possible to query AD from javascript?

I'm working from within SharePoint, and I can get the current SharePoint user's information using some js I found on a blog.

But I'm wondering if I can then query AD to see if the current user is in a specific AD group.

+1  A: 

I think you'd be better off writing a quick asp.net page that you could call via AJAX and get some JSON back. .NET directory services class are going to be much better at talking to Active Directory than javascript, unless you can find a js library specifically for this (which I haven't been able to find).

squillman
I already have SharePoint consuming a few .NET web pages / web apps as web parts.My concern is that SharePoint takes so long to load them.
vwfreak034
A: 

There is no way known to me how one could access AD from a client script. I could only think of some kind of an ActiveX control which does the job, however that 1) would work only in IE 2) would also be limited to zone settings in IE.

So, the reason is why you need this. Most probably, to be able to show the user something or hide something from the user. If this is the case, you could think of applying the "target audiences" solution to your page (see here - http://office.microsoft.com/en-us/sharepointserver/HA101690531033.aspx). For instance, add two versions of your webpart to the page, one for users who are in the group and another for users who aren't.

If you really need to have this information on the client side in JS, you can create some "AD helper" web service on your server and call into that service using AJAX, as per @squillman's post.

naivists