Solved

Active Directory users into Infopath Drop down list box.

Posted on 2013-01-09
4
900 Views
Last Modified: 2013-07-23
hI,

I have Developed custom webservice to get AD users and got users list when I tried to invoke operation on server.

Then I created data connection in infopath form and added as external data source for a drop down list box but I didn't get any values into drop down box and I didn't get error either.

Can anybody please help me out to resolve this issue?

Any help would be appreciated.

Here I am adding my code, please let me know if I am doing some thing wrong.

public string GetProperty(SearchResult searchResult, string propertyName)
        {
            if (searchResult.Properties.Contains(propertyName))
            {
                return searchResult.Properties[propertyName][0].ToString();
            }
            else
            {
                return string.Empty;
            }
        }

        public DataTable CreateDataTable()
        {
            DataTable dtUsers = new DataTable();
            dtUsers.Columns.Add("UserName");
            return dtUsers;
        }
        [WebMethod]
        public DataSet GetActiveDirectoryUsers()
        {
            DirectoryEntry entry = null;
            DirectorySearcher searcher = null;
            DataSet dsUsers = null;

            try
            {
                DataTable dtUsers = new DataTable();
                dtUsers.Columns.Add("UserName");

                DataRow row1 = dtUsers.NewRow();
                row1["UserName"] = "ashok";
                dtUsers.Rows.Add(row1);
                dsUsers = new DataSet();
                dsUsers.Tables.Add(dtUsers);


                entry = new DirectoryEntry("LDAP://OU=XXX_USERS,OU=XX_XX,DC=XXXXX,DC=com");
                searcher = new DirectorySearcher(entry);
                //searcher.SearchScope=SearchScope.Subtree;
                searcher.Filter = "(&(objectClass=user))";
                SearchResultCollection resultColl = searcher.FindAll();
                if (resultColl.Count > 0)
                {
                    //DataTable dtUsers = new DataTable();
                    //dtUsers.Columns.Add("UserName");
                    foreach (SearchResult resultSet in resultColl)
                    {
                        if (!string.IsNullOrEmpty(GetProperty(resultSet, "title")) && !string.IsNullOrEmpty(GetProperty(resultSet, "Manager")))
                        {
                            DataRow row = dtUsers.NewRow();
                            row["UserName"] = GetProperty(resultSet, "Name");
                            dtUsers.Rows.Add(row);
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                if (searcher != null) searcher.Dispose();
                if (entry != null) entry.Dispose();
            }

            return dsUsers;
        }
0
Comment
Question by:aaedla
  • 2
  • 2
4 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
ID: 38761696
Hi,
have you tested your web service that it returns a dataset?

Please review the steps mentioned here
http://alekhyakodamsharepoint.wordpress.com/2012/05/03/infopath-2010-form-binding-data-to-dropdownlist-from-web-service/

HTH
Rainer
0
 

Author Comment

by:aaedla
ID: 38763037
Thank you Rainer for your comments.

I have tested web service and returned results.
I did exactly what "AlekhyaKodam" did, the only difference is I am trying to pull data from AD.

Regards.
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 38764887
Hi,
where is your web service deployed? Dedicated web app? In the Sharepoint web services site/folder?
Perhaps its an authentication issue?
You might try to use Fiddler as a proxy (or Firefox/Firebug) and see what calls are going out from your client and what the service returns.
HTH
Rainer
0
 

Author Comment

by:aaedla
ID: 38765700
Rainer,

i have deployed in layouts folder(14\TEMPLATES\LAYOUTS\CustomWebService\webservice.asmx).

ok...let me try to use fiddler.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now