Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

At my wits end with InfoPath and Sharepoint user pre-population

  Asked By: Tessa    Date: Dec 25    Category: Sharepoint    Views: 1952

I am trying to pull data from LDAP and pre-populate an InfoPath form
with that data. I was able to find a way to do this, not sure if it is
the best but it works fine inside InfoPath on my Virtual PC. Once I
move it to SharePoint and try to open a new document in the form
library it does not work. I did set it to Full Trust.

I am wondering if I could pull user data from SharePoint it's self if
that would be better. I have looked every where and some ideas from
here but nothing seems to work. Does anyone have an idea.

Share: 

 

6 Answers Found

 
Answer #1    Answered By: Alicia Scott     Answered On: Dec 25

We're going to need more information than "it does not work". What
behavior did you expect, and what did you actually get? Was there an error
message, and if so, what was it? Where is the LDAP web service hosted? Is
there a permissions problem when you call it explicitly from the new
location?

 
Answer #2    Answered By: Mike Lamb     Answered On: Dec 25

I do not get an error when I run it in Infopath, but when I run it
in sharepoint  I get this error:

An operations error occurred.

** I think there is more to the error, I submitted this artice a
couple of days ago
www.infopathdev.com/forums/p/9468/33524.aspx

** I am not using a web service i am just using the code behind with
the code seen below.


here is the code in my load event:

//***************************************************************

try
{
// Get the user  name of the current user.
string userName = this.Application.User.UserName;

// Create a DirectorySearcher object using the user
name
// as the LDAP search filter. If using a directory
other
// than Exchange, use sAMAccountName instead of
mailNickname.
DirectorySearcher searcher = new DirectorySearcher
("(sAMAccountName=" + userName + ")");

// Search for the specified user.
SearchResult result = searcher.FindOne();

// Make sure the user was found.
if (result == null)
{
//alert(string "Error finding user" + userName);
XPathNavigator xnMyForm = this.CreateNavigator();
XmlNamespaceManager ns = this.NamespaceManager;
xnMyForm.SelectSingleNode
("/my:webRequest/my:errorMessage", ns)
.SetValue("Error finding user" + userName);

}
else
{
// Create a DirectoryEntry object to retrieve the
collection
// of attributes (properties) for the user.
DirectoryEntry employee = result.GetDirectoryEntry
();

string FirstName = Convert.ToString(employee.Properties
["givenName"].Value);
if (string.IsNullOrEmpty(LastName))
{
FirstName = "N/A";
}
else
{
FirstName = employee.Properties
["givenName"].Value.ToString();
}


string LastName = Convert.ToString
(employee.Properties["sn"].Value);
if (string.IsNullOrEmpty(LastName))
{
LastName = "N/A";
}
else
{
LastName = employee.Properties
["sn"].Value.ToString();
}
string Mail = Convert.ToString(employee.Properties
["mail"].Value);

if (string.IsNullOrEmpty(Mail))
{
Mail = "N/A";
}
else
{
Mail = employee.Properties
["mail"].Value.ToString();
}



string Location = Convert.ToString
(employee.Properties["physicalDeliveryOfficeName"].Value);

if (string.IsNullOrEmpty(Location))
{
Location = "N/A";
}
else
{
Location = employee.Properties
["physicalDeliveryOfficeName"].Value.ToString();
}



string Title = Convert.ToString
(employee.Properties["title"].Value);

if (string.IsNullOrEmpty(Location))
{
Title = "N/A";
}
else
{
Title = employee.Properties
["title"].Value.ToString();
}

string Phone = Convert.ToString
(employee.Properties["telephoneNumber"].Value);

if (string.IsNullOrEmpty(Phone))
{
Phone = "N/A";
}
else
{
Phone = employee.Properties
["telephoneNumber"].Value.ToString();
}




string Department = Convert.ToString
(employee.Properties["department"].Value);

if (string.IsNullOrEmpty(Department))
{
Department = "N/A";
}
else
{
Department = employee.Properties
["department"].Value.ToString();
}


// Create an XPathNavigator to walk the main data
source of the form.
XPathNavigator xnMyForm = this.CreateNavigator();
XmlNamespaceManager ns = this.NamespaceManager;

// Set the fields in the form.
xnMyForm.SelectSingleNode
("/my:webRequest/my:ContactInformation/my:Requesters_Name", ns)
.SetValue(FirstName + ' ' + LastName);

xnMyForm.SelectSingleNode
("/my:webRequest/my:ContactInformation/my:Requesters_Email", ns)
.SetValue(Mail);
xnMyForm.SelectSingleNode
("/my:webRequest/my:ContactInformation/my:Requesters_Phone", ns)
.SetValue(Phone);

xnMyForm.SelectSingleNode
("/my:webRequest/my:ContactInformation/my:Requesters_Location", ns)
.SetValue(Location);

xnMyForm.SelectSingleNode
("/my:webRequest/my:ContactInformation/my:Requesters_Department", ns)
.SetValue(Department);

// Clean up.
xnMyForm = null;
searcher.Dispose();
result = null;
employee.Close();
}

}
catch (Exception ex)
{
//MessageBox.Show("The following error occurred: " +
// ex.Message.ToString());
XPathNavigator xnMyForm = this.CreateNavigator();
XmlNamespaceManager ns = this.NamespaceManager;
xnMyForm.SelectSingleNode
("/my:webRequest/my:errorMessage", ns)
.SetValue(":" + ex.Message);
//throw;
}
}

 
Answer #3    Answered By: Jose Scott     Answered On: Dec 25

o you went with the code-behind. As long as you're only loading
it when the form starts up, that should work  just fine.

Does the SharePoint server have access to the domain controller?

Also, are there any notable error messages in either the server's event logs
or the 12/LOGS folder? I'd suggest running a failed attempt and having the
logs ready to refresh right after you do it (to make the needle-finding a
little easier).

 
Answer #4    Answered By: Taylor Clark     Answered On: Dec 25

I assume the sharepoint  can talk to the domain controller, cause
the infopath  pulls the user  data just fine  on the server and we have
user accounts on the sharepoint site that are coming from AD accounts:

There where no errors in 12/logs folder, but i did see this error
several times in iis:

-------------------------------------------------------------
The SSP Timer Job Distribution List Import Job was not run.

Reason: Logon failure: unknown user name or bad password

Technical Support Details:
System.ComponentModel.Win32Exception: Logon failure: unknown user
name or bad password
at
Microsoft.Office.Server.Utilities.WindowsSecurity.GetUserTokenFromCred
entials(String userDomainName, String password, LogonType logonType)
-------------------------------------------------

 
Answer #5    Answered By: Anthony Rutledge     Answered On: Dec 25

I'm confused; I thought the infopath  form was *not* pulling the data
properly on the server. So you're saying that the data  does come in
correctly, but you're just getting an extraneous error message?

 
Answer #6    Answered By: Heena Nagori     Answered On: Dec 25

No when I open  a new form from the sharepoint  library list the form
does open, but there is no pre-populated data  being shown and the
only errors i could find  where in IIS like shown below. I assume it
has somthing to do with permissions in iss or somthing. I am running
the sharepoint site with a site admin account so that account should
have full  rights.

 




Tagged: