Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Active Directory users into Infopath Drop down list box.

Posted on 2013-01-09
4
Medium Priority
?
958 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
[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
  • 2
  • 2
4 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 1500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Before you can digitally sign infopath forms, you must have a digital certificate. Microsoft Certificate Services will need to be enabled on a Windows Server 2008 to facilitate the creation and verification of the digital certifciates on the web ser…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

618 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