Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / December 2006

Tip: Looking for answers? Try searching our database.

Search Active Directory - security error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
steve@verizon.net - 08 Dec 2006 21:03 GMT
I have the following code in an infopath form - i get a security
exception on the line:
 rootDse = New DirectoryEntry("LDAP://rootDSE")

The same code works fine if i build the app as a Windows Application.

any ideas?

 Dim domainSid() As Byte
           Dim rootDse As DirectoryEntry
           Dim domainRoot As DirectoryEntry
           Dim searcher As DirectorySearcher
           Dim results As SearchResultCollection
           Dim objCollResultProperty As ResultPropertyCollection
           Dim objCollResultPropertyValue As
ResultPropertyValueCollection
           Dim result As SearchResult

           rootDse = New DirectoryEntry("LDAP://rootDSE")
           domainRoot = New DirectoryEntry("LDAP://" +
DirectCast(rootDse.Properties("defaultNamingContext").Value, String))

           searcher = New DirectorySearcher(domainRoot)
           domainSid =
DirectCast(domainRoot.Properties("objectSID").Value, Byte())
           searcher.Filter = ("(&(objectClass=user)(samaccountname=" &
Environment.UserName() & "))")
           searcher.Filter = ("(&(objectClass=user)(samaccountname=" &
"kstarkey" & "))")

           results = searcher.FindAll()
           result = results.Item(0)

           objCollResultProperty = result.Properties

           objCollResultPropertyValue =
objCollResultProperty.Item("displayname")
           Dim GetName As String

           GetName = objCollResultPropertyValue.Item(0)

           'thisXDocument.DOM.selectSingleNode("//my:singleName").text
= GetName

           results.Dispose()
           searcher.Dispose()
           domainRoot.Dispose()
           rootDse.Dispose()
S.Y.M. Wong-A-Ton - 09 Dec 2006 02:07 GMT
What is the full security error message? I suspect you may be having a code
access security issue and may have to give your form full trust for it to
work.
---
S.Y.M. Wong-A-Ton

> I have the following code in an infopath form - i get a security
> exception on the line:
[quoted text clipped - 44 lines]
>             domainRoot.Dispose()
>             rootDse.Dispose()
steve@verizon.net - 11 Dec 2006 16:26 GMT
Thanks for responsing.  The full message is:

System.Security.SecurityException
Security error.
  at
Absence_Request_Trusted.Absence_Request_Trusted.OnLoad(DocReturnEvent
e)
  at
Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper.OnLoad(DocReturnEvent
pEvent)

I could make the form fully trusted since all the users are internal to
our project and there are not that many users.  Can I run RegForm with
an InfoPath form that uses Managed Code?  The form itself doesn't seem
to be in the Visual Studio Project/Absence Request etc... folder as i
expected (I'm new to this, probably a stupid question)

the other complication is that I want to ultimately store the form on
SharePoint.  I've read that RegForm forms can be used w/ SharePoint,
and I've also read the opposite.

thanks again

steve

> What is the full security error message? I suspect you may be having a code
> access security issue and may have to give your form full trust for it to
[quoted text clipped - 50 lines]
> >             domainRoot.Dispose()
> >             rootDse.Dispose()
steve@verizon.net - 11 Dec 2006 16:36 GMT
> Thanks for responsing.  The full message is:
>
[quoted text clipped - 75 lines]
> > >             domainRoot.Dispose()
> > >             rootDse.Dispose()

I see the form now - it's in the BIN/DEBUG folder......... (weird) -
should i run RegForm against that, and then publish the result to
SharePoint?
S.Y.M. Wong-A-Ton - 12 Dec 2006 04:57 GMT
This does not look like a code access security permission error, so giving
your form full trust might not solve the problem. Perhaps the user account
being used to access Active Directory does not have permission to do so?

There are 2 ways to give your form full trust: 1. Install it using regform
or 2. sign it with a digital certificate. I meant the latter. Since the form
template will be published to SharePoint, it is best to use the second option.
---
S.Y.M. Wong-A-Ton


> Thanks for responsing.  The full message is:
>
[quoted text clipped - 75 lines]
> > >             domainRoot.Dispose()
> > >             rootDse.Dispose()
Andy Bonner - 18 Dec 2006 21:02 GMT
Try the method I show in my blog instead, using the GetUserInfo method of
the UserGroup webservice.  It's in C# but you should get the idea

http://blogs.vbcity.com/skullcrusher/archive/2006/12/18/7634.aspx

Regards
Andy

>I have the following code in an infopath form - i get a security
> exception on the line:
[quoted text clipped - 44 lines]
>            domainRoot.Dispose()
>            rootDse.Dispose()

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.