472,341 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,341 software developers and data experts.

LDAP + index was out of range

I have an application that look up user's firstname, lastname, email from Active Directory and dispay any open ticket associated with the user. The program runs correctly for all US users but it doesn't run for users in Asia even though we share the same network. When I log in as an asian user and run the http://servername/applicationNAme, I get the following error.
Index was out of range. Must be non-negative and...

Here is the code used in the application
Public Class WebForm1
Inherits System.Web.UI.Page



<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Designer.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Dim con As SqlConnection
Dim username As String
Dim UserFN As String
Dim UserLN As String
Dim UserEmail As String
Dim StrSortField As String

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LoadPage()

End Sub
Sub LoadPage()
con = New SqlConnection("Server=data source;uid=xxx;pwd=xxxx;database=xxxxx")

username = Request.ServerVariables("REMOTE_USER").ToString

If username = "" Then
DisplayError()
Else
SearchAD(username)
UserNamelbl.Text = "Welcome, " + UserFN + " " + UserLN + "."

CreateDataGrid()
End If
End Sub
Sub SearchAD(ByVal SUserName As String)


Dim UName() As String
UName = SUserName.Split("\")

Dim opath As New DirectoryEntry
opath.Path = "LDAP://" + UName(0) + ".com"
opath.Username = "Domain\server"
opath.Password = "XXXX"



Dim osearcher As New DirectoryServices.DirectorySearcher(opath)
Dim oresult As SearchResult
osearcher.SearchScope = SearchScope.Subtree
osearcher.PropertiesToLoad.Add("sn")
osearcher.PropertiesToLoad.Add("givenname")
osearcher.PropertiesToLoad.Add("mail")
osearcher.Filter = "(&(objectclass=user)(samaccountname=" & UName(1) & "))"
oresult = osearcher.FindOne
UserFN = oresult.Properties("givenname")(0).ToString()
UserLN = oresult.Properties("sn")(0).ToString()
UserEmail = oresult.Properties("mail")(0).ToString()

End Sub

Sub DisplayError()

ErrorLbl.Text = "Error: not able to complete user identification."

End Sub
Sub CreateDataGrid()

Dim IncidentsWhere As String
Dim ProblemsWhere As String
Dim ChangesWhere As String
Dim TicketsWhere As String
Dim ClosedDate As String
Dim OrderBy As String

If StrSortField = "" Then
StrSortField = "[Ticket_Number]"
End If

OrderBy = " ORDER BY " + StrSortField


Select Case ClosedSelect.SelectedValue.ToString
Case "NoClosed"



TicketsWhere = " AND status <> 'closed'"
Case "Closed2Weeks"
ClosedDate = DateAdd("d", -14, Now)

TicketsWhere = " AND (status <> 'closed' OR close_time > '" + ClosedDate + "')"
Case "ClosedMonth"
ClosedDate = DateAdd("d", -31, Now)

TicketsWhere = " AND (status <> 'closed' OR close_time > '" + ClosedDate + "')"
Case "Closed3Months"
ClosedDate = DateAdd("d", -93, Now)

TicketsWhere = " AND (status <> 'closed' OR close_time > '" + ClosedDate + "')"
End Select

Dim IncidentCmdStr As String


IncidentCmdStr = "SELECT reference_key AS [Ticket_Number], brief_description AS [Brief_Description], status AS [Work_Status], (CASE WHEN status = 'closed' THEN NULL WHEN status <> 'closed' THEN cast(update_time as varchar(50)) END) AS [Last_Update], CAST(assignment As VARCHAR(50))AS [Assigned_To] FROM workm1 WHERE reference_filename <> 'cm3t' AND bd_mail LIKE '%" + UserEmail + "%' " + TicketsWhere

IncidentCmdStr = IncidentCmdStr + OrderBy 'added sort order 1/4/06 -JAF

CreateTable(IncidentCmdStr, Dgrd)


End Sub
Sub AddData(ByVal cmd As SqlCommand, ByRef datagrd As DataGrid)
con.Open()

datagrd.DataSource = cmd.ExecuteReader
datagrd.DataBind()
con.Close()

End Sub

Private Sub ClosedSelect_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClosedSelect.SelectedIndexChanged
CreateDataGrid()
End Sub

Public Sub dgrd_SortCommand(ByVal s As System.Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEvent Args)
StrSortField = e.SortExpression
LoadPage()

End Sub

Structure change
Dim Ticket_Number As String
Dim Brief_Description As String
Dim Work_Status As String
Dim Last_Update As String
Dim Assigned_To As String

End Structure


Sub CreateTable(ByVal cmdstr As String, ByVal dgrd As DataGrid)

Dim rdr As SqlDataReader
Dim ChangeArray As New ArrayList
Dim Iarray As New ArrayList
Dim chArray As New ArrayList
Dim nArray As New ArrayList
Dim prevNum As String
Dim count As Integer = -1
Dim m As Integer = 0
Dim counting As Boolean = False
Dim TimeCalcStr As String
Dim descStr As String
Dim LastCH As String
Dim NewUDTime As String

Dim ds As DataSet
con = New SqlConnection("Server=xxxx;uid=xxxx;pwd=xxx;databa se=xx")

con.Open()
Dim cmd As New SqlCommand(cmdstr, con)
cmd.CommandTimeout = 300
rdr = cmd.ExecuteReader()

While rdr.Read()

Dim rChange As New change

rChange.Ticket_Number = rdr("Ticket_Number").ToString
rChange.Brief_Description = rdr("Brief_Description").ToString
rChange.Work_Status = rdr("Work_Status").ToString
rChange.Last_Update = rdr("Last_Update").ToString
rChange.Assigned_To = rdr("Assigned_To").ToString


ChangeArray.Add(rChange)


End While
con.Close()

Dim CurrentChange As change
Dim PrevChange As change

For m = 0 To ChangeArray.Count - 1
CurrentChange = ChangeArray.Item(m)

TimeCalcStr = CurrentChange.Last_Update
If Not TimeCalcStr = "" Then
Dim convertWorkStatus As DateTime = DateTime.Parse(TimeCalcStr)
Dim newESTWorkStatus As DateTime
newESTWorkStatus = convertWorkStatus.AddHours(-5)
NewUDTime = convertWorkStatus
NewUDTime += " GMT <br>" + newESTWorkStatus + " EST"
CurrentChange.Last_Update = NewUDTime
Else
CurrentChange.Last_Update = TimeCalcStr
End If


If m = 0 Then
descStr = CurrentChange.Brief_Description
Else
If CurrentChange.Ticket_Number = PrevChange.Ticket_Number Then
descStr += "<br>" + CurrentChange.Brief_Description
counting = True
Else
If counting = True Then
PrevChange.Brief_Description = descStr
Iarray.Add(PrevChange)
descStr = CurrentChange.Brief_Description
counting = False
Else
Iarray.Add(PrevChange)
descStr = CurrentChange.Brief_Description

End If
End If

End If
PrevChange = CurrentChange
Next
PrevChange.Brief_Description = descStr
PrevChange.Last_Update = NewUDTime
Iarray.Add(PrevChange)

Dim dt As New DataTable

Dim dc1 As New DataColumn
dc1.ColumnName = "Ticket_Number"
Dim dc2 As New DataColumn
dc2.ColumnName = "Brief_Description"
Dim dc3 As New DataColumn
dc3.ColumnName = "Work_Status"
Dim dc4 As New DataColumn
dc4.ColumnName = "Last_Update"
Dim dc5 As New DataColumn
dc5.ColumnName = "Assigned_To"

dt.Columns.Add(dc1)
dt.Columns.Add(dc2)
dt.Columns.Add(dc3)
dt.Columns.Add(dc4)
dt.Columns.Add(dc5)



Dim i As Integer
For i = 0 To Iarray.Count - 1
Dim cChange As New change
cChange = Iarray.Item(i)

Dim dr As DataRow
dr = dt.NewRow()

dr("Ticket_Number") = cChange.Ticket_Number
dr("Brief_Description") = cChange.Brief_Description
dr("Work_Status") = cChange.Work_Status
dr("Last_Update") = cChange.Last_Update
dr("Assigned_To") = cChange.Assigned_To

dt.Rows.Add(dr)



Next

Dim c As DataGridColumn


ds = New DataSet
ds.Tables.Add(dt)


dgrd.DataSource = ds.Tables(0)
dgrd.DataBind()
End Sub

Private Sub Dgrd_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Dgrd.SelectedIndexChanged

End Sub
End Class

The problem again is the application runs fine for users in the US but not for users in ASIA.

Any help would be really appreciate
Nov 15 '06 #1
0 1227

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Colin Steadman | last post by:
I'm using the function copied below to authenticate users in LDAP before allowing them onto our intranet site. This works great! But what I'd like...
3
by: Frank Drebin | last post by:
I have a need to allow other LDAP-compliant customers that want to integrate thier own single-signon to be able to map to accounts in my SQL2K...
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am...
5
by: Melissa Evans | last post by:
Hi. I'm new to Python. :) I've modified grappy.py, http://www.stacken.kth.se/~mattiasa/projects/grappy/, a postfix policy daemon for...
85
by: Russ | last post by:
Every Python programmer gets this message occasionally: IndexError: list index out of range The message tells you where the error occurred, but...
2
by: Steve JORDI | last post by:
Hi, I'm checking a user identity on a secure LDAP server using the following code: $ldapconn = ldap_connect("ldaps://myserver.mycompany.ch", 636...
1
by: apedosmil8 | last post by:
Hello, I am really stuck on how to get a LDAP connection with my college. ...
2
by: Lars | last post by:
Hi I got some programming experience and I recently started looking into Python. I've read much of the tutorial from 2.6 documentation. But it was...
1
by: =?Utf-8?B?SkI=?= | last post by:
Hello As I debug the C# code with a break point and by pressing F11 I eventually get a message stating: ContextSwitchDeadlock was detected...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.