Error to get data from Active Directory - InfoPath Dev
in

InfoPath Dev

Error to get data from Active Directory

Last post 03-26-2013 08:31 AM by jorge23. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 08-02-2011 09:42 PM

    Error to get data from Active Directory

    Hi All,

    i have a problem to get data from Active Directory like below:

     "System.Security.SecurityException
    Request for the permission of type 'System.DirectoryServices.DirectoryServicesPermission, System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.
       at test2.FormCode.CTRL2_5_Clicked(Object sender, ClickedEventArgs e)
       at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
       at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)"

    how to solve this problem?

    my code below:

    Try

    Dim userName As String = Me.Application.User.UserName

    Dim searcher As DirectorySearcher = New DirectorySearcher("(mailNickname=" + userName + ")")

    Dim result As SearchResult = searcher.FindOne()

    Dim employee As DirectoryEntry = result.GetDirectoryEntry()

    Dim FirstName As String = employee.Properties("givenName").Value.ToString()

    Dim xnMyForm As XPathNavigator = Me.CreateNavigator()

    Dim ns As XmlNamespaceManager = Me.NamespaceManager

    xnMyForm.SelectSingleNode("/my:myFields/my:FirstName", ns).SetValue(FirstName)

    Catch ex As ExceptionMessageBox.Show("The following error occurred: " + _

    ex.Message.ToString())

    Throw

    End Try

    Filed under:
  • 08-03-2011 08:09 AM In reply to

    Re: Error to get data from Active Directory

    Looks like you need to change your form to full trust. This line of the error message is the give away:

    System.Security.SecurityException

    Hilary Stoupa

  • 08-03-2011 10:03 PM In reply to

    Re: Error to get data from Active Directory

    thanks Hilary, now it works.

  • 03-26-2013 08:31 AM In reply to

    Re: Error to get data from Active Directory

    my form is setup to  automatically determine security level.

     it seems the issue is local to user's computer, not profile related. when user signs into citrix using her profile she is able to get signature to work with the form with no porblem at all.

     

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.