?
Solved

Active Directory users into Infopath Drop down list box.

Posted on 2013-01-09
4
Medium Priority
?
945 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Summary In SharePoint 2010 it is easy to create custom color themes to jazz up a site. Theme colors can also be created in PowerPoint 2010 with a few clicks. But how do the chosen colors actually look in the SharePoint site? The attached PowerPoint…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

752 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