I came to know that my problem will be Probably with the Code Access
Security(CAS) but till now I did not figure out how to implement
that if any body has gone through that before
And Here is My Code
[ Dim btnsearch As New Button
Dim txtName As New TextBox
Dim dgdetails As New DataGrid
Dim htable As New Hashtable
Dim srchName As String
Dim DS As DataSet
Public Sub btnsearch_clicked(ByVal sender As Object, ByVal e As
EventArgs)
Try
srchName = Trim(txtName.Text)
txtName.Text = Getloggedinuser()
htable = GetEmpName(srchName)
dgdetails.DataSource = htable
dgdetails.DataBind()
Catch ex As Exception
txtName.Text = (ex.ToString)
End Try
End Sub
Protected Overrides Sub Createchildcontrols()
AddHandler btnsearch.Click, AddressOf btnsearch_clicked
With Controls
.Add(btnsearch)
.Add(txtName)
.Add(dgdetails)
End With
End Sub
Protected Overrides Sub RenderWebPart(ByVal output As
System.Web.UI.HtmlTextWriter)
Try
' renderchildren(output)
btnsearch.Text = "Click Here"
output.Write("<table border=1>")
output.Write("<tr><td>")
btnsearch.RenderControl(output)
output.Write("</td><td>")
txtName.RenderControl(output)
output.Write("</td></tr><tr><td colspan=2 height='200'>")
dgdetails.RenderControl(output)
output.Write("</td></tr></table>")
Catch ex As Exception
output.Write(ex.ToString)
End Try
End Sub
Private Function GetEmpName(ByVal sAMAccountName As String) As
Hashtable
Try
Dim EmpName As String
Dim EmpExt As String
htable = New Hashtable
Dim strpath As String = "LDAP://DC=????,DC=?????,DC=net"
Dim DE As New System.DirectoryServices.DirectoryEntry
(strpath, "domainname\UserID", "password")
Dim searcher As New DirectorySearcher(DE)
' searcher.Filter = "(&(objectClass=user)(anr= " &
sAMAccountName & "))"
searcher.Filter = "(&(objectCategory=person)
(objectClass=user)(anr=" & sAMAccountName & " * ))"
For Each result As SearchResult In searcher.FindAll
EmpExt = 0 '(result.Properties("IPphone")(0))
EmpName = (result.Properties("displayName")(0))
htable.Add(EmpName, EmpExt)
Next
Return htable
Catch ex As Exception
txtName.Text = ("In the function:: " + ex.ToString)
End Try
End Function]