S
steve
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()
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()