Calling xp_fixeddrives from IP form - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Calling xp_fixeddrives from IP form

Last post 08-15-2011 08:29 PM by Jimmy. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 08-15-2011 06:17 AM

    • lisaa
    • Not Ranked
    • Joined on 08-15-2011
    • Posts 2

    Calling xp_fixeddrives from IP form

    I'm trying to call the stored procedure, xp_fixeddrives, from an InfoPath 2010 but need to make it 2003 compatible if possible.  I'm familiar with doing C# coding in the form but calling this stored procedure has me stumped.  I'm getting the following exception on the connection.Open() statement below.  I'm an admin on the development machine (Win 7/SharePoint installed directly on it) and I have db_owner permissions on the database.

    System.Security.SecurityException was unhandled by user code
      Message="Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
      Source="mscorlib"

    Code sample:

    string connString = "Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=WSS_NTLMOnlyContent;Data Source=.\\Sharepoint;";using (SqlConnection connection = new SqlConnection(connString))

    {

    // Create the command and set its properties.

    SqlCommand command = new SqlCommand();

    command.Connection = connection;

    command.CommandText =
    "xp_fixeddrives";

    command.CommandType = CommandType.StoredProcedure;

    // Open the connection and execute the reader.

    connection.Open(); // getting permissions issue

    SqlDataReader reader = command.ExecuteReader();if (reader.HasRows)

    {

    while (reader.Read())

    {

    Console.WriteLine("{0}: {1:C}", reader[0], reader[1]);

    }

    }

    else

    {

    Console.WriteLine("No rows found.");

    }

    reader.Close();

    } // end using

     

    Does anyone have ideas?  

     

  • 08-15-2011 09:46 AM In reply to

    Re: Calling xp_fixeddrives from IP form

    Typically, forms have to be full trust to execute SQL from code.  One way around this is to create and use a web service, which doesn't require having any code in your form at all.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 08-15-2011 10:06 AM In reply to

    • lisaa
    • Not Ranked
    • Joined on 08-15-2011
    • Posts 2

    Re: Calling xp_fixeddrives from IP form

    Thanks for the info.  That did allow me to get the values from the stored procedure output.  If I develop my own web service and then simply call it via the InfoPath form, can my form remain Domain trusted?  Or does the form still need to be full trust to call my web service?  I ask because I've only called SharePoint web services from InfoPath to stuff data from the form into a SharePoint list (or read it).

  • 08-15-2011 08:29 PM In reply to

    Re: Calling xp_fixeddrives from IP form

    If you use InfoPath's built-in data connection features to access your own web service, domain trust should be fine as long as the form is published to the same domain as the web service.  I think domain trust will still work if they're not on the same domain, though the user will probably be prompted for approval.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.