Solved

Active Directory users into Infopath Drop down list box.

Posted on 2013-01-09
4
889 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Setting location of a form 4 22
Round a string to two digits 12 25
Showdialog 8 21
VBA in SharePoint 3 19
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

15 Experts available now in Live!

Get 1:1 Help Now