Last post May 16, 2008 03:16 AM by Jorus
May 14, 2008 05:36 PM|Jorus|LINK
I am try to create a list of all the distribution groups in an OU. I am using the ADservice method and the MPSSampleWeb.
ADSearchRequest ADSearchRequestObj = new ADSearchRequest();
ADSearchRequestObj.Data.path = serviceModuleProperties.SelectedNodeLDAPPath.ToString();
ADSearchRequestObj.Data.preferredDomainController = HostingUtility.GetConfigItem(SettingsKey.Pdc);
ADSearchRequestObj.Data.filter = "(&(objectCategory=group)";
ArrayOfADSearchRequestDataPreferencePreference searchScopePref = new ArrayOfADSearchRequestDataPreferencePreference;
searchScopePref = new ArrayOfADSearchRequestDataPreferencePreference();
searchScopePref.searchPref = new object;
searchScopePref.searchPref = (object)"ADS_SEARCHPREF_SEARCH_SCOPE";
searchScopePref.type = new object;
searchScopePref.type = (object)"ADSTYPE_INTEGER";
searchScopePref.value = new object;
searchScopePref.value = (object)"ADS_SCOPE_ONELEVEL";
ADSearchRequestObj.Data.preferences = searchScopePref;
ArrayOfADSearchRequestDataPropertyProperty searchScopeProp = new ArrayOfADSearchRequestDataPropertyProperty;
searchScopeProp = new ArrayOfADSearchRequestDataPropertyProperty();
searchScopeProp.name = "Name";
ADSearchRequestObj.Data.propertyList = searchScopeProp;
ADSearchResponse ADSearchResponseObj = (ADSearchResponse)WebServiceGeneral.Submit(ServiceModuleConstants["HostedADNamespace"].ToString(), ServiceModuleConstants["ADSearch"].ToString(),ADSearchRequestObj, true);
I get the following error return when I attempt to submit the web serivce call.
Error: Object reference not set to an instance of an object. Please check logs for more details.
Any ideas on what i am doing wrong? or is there another method to do it?
May 14, 2008 06:36 PM|johram|LINK
I haven't used this method myself, but it seems a bit cumbersome. Why don't you use System.DirectoryServices instead? It's somewhat easier to use. Writing from the top of my head here so the syntax might not be entirely correct:
using (DirectoryEntry root = new DirectoryEntry("LDAP://ou=myou,dc=somedomain,dc=com"))
DirectorySearcher searcher = new DirectorySearcher(root);
searcher.Filter = "(objectClass=group)";
using (SearchResultCollection results = searcher.FindAll())
foreach (SearchResult result in results)
string groupName = result.Properties["cn"].ToString();
May 15, 2008 11:20 PM|Jorus|LINK
I am trying to use the web services as part of the MPS sample web site. If I use the directorysearcher from .NET, then I will need to authenicate against AD to perform the search. As the IIS service is doing to the request it would use it's login.
So far I have no been able to get the aspx code behind page to work correctly with ether the ADsearch from MPS or Directorysearch. I am starting to think I will just create a web service to perform AD and SQL searchers. Then I will be able to control the
I would still like to know if anyone has gotten the ADsearch from the MPS working correctly.
May 16, 2008 02:42 AM|johram|LINK
OK. Can you put a breakpoint on the first statement and then step through each statement to determine the row on which the error message appears?
May 16, 2008 03:16 AM|Jorus|LINK
I have it working now. I was able to use the ADsearch. I had a issue with the returning value, but I was able to get it working using xmlNode searches to return the results I needed.
Thanks for the help.