Quantcast
Channel: Alguém já viu esse erro?
Viewing all articles
Browse latest Browse all 2

Alguém já viu esse erro?

$
0
0

Estou realizando uma consulta no AD, tenho um for each para gerar o resultado, o que percebi que quando tenho muitos registro ele reporta o erro abaixo:

System.DirectoryServices.DirectoryServicesCOMException was unhandled by user code
  ErrorCode=-2147024662
  Message="More data is available.
"
  Source="System.DirectoryServices"
  StackTrace:
       at System.DirectoryServices.SearchResultCollection.ResultsEnumerator.MoveNext()
       at _Default.queryBrasil() in C:\WebSite5\Default.aspx.vb:line 160
       at _Default.Button1_Click(Object sender, EventArgs e) in C:\WebSite5\Default.aspx.vb:line 14
       at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
       at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

 

Meu código é:

 

For

Each result In results 

'converte accountexpires de Large/Integer para DateTime

searcher.PropertiesToLoad.Add(

"pwdLastSet")

Dim lastexpires AsLong = result.Properties("pwdLastSet")(0)

Dim dtLastLoginexpires As DateTime = DateTime.FromFileTime(lastexpires)

Dim lastlogonuser1 AsString = dtLastLoginexpires.ToShortDateString() + " " + dtLastLoginexpires.ToShortTimeString()

 

'checa se existe atributo em branco

If result.Properties("lastlogontimestamp").Count > 0 Then

'converte laslogontimestamp de Large/Integer para DateTime

searcher.PropertiesToLoad.Add(

"lastlogontimestamp")

Dim lastlogontimestamp AsLong = result.Properties("lastlogontimestamp")(0)

Dim dtLastLoginTimeStamp As DateTime = DateTime.FromFileTime(lastlogontimestamp)

Dim lastlogonuser AsString = dtLastLoginTimeStamp.ToShortDateString() + " " + dtLastLoginTimeStamp.ToShortTimeString()

If result.Properties("displayname").Count > 0 Then

If result.Properties("company").Count > 0 Then

If result.Properties("postofficebox").Count > 0 Then

If result.Properties("description").Count > 0 Then

'Gera arquivo de saída para Import

arq.Writeline(result.Properties(

"sAMAccountName").Item(0) & ";"& result.Properties("displayname").Item(0) & ";"& result.Properties("company").Item(0) & ";"& result.Properties("description").Item(0) & ";"& result.Properties("useraccountcontrol").Item(0) & ";"& result.Properties("co").Item(0) & ";"& result.Properties("postofficebox").Item(0) & ";"& lastlogonuser1 & ";"& lastlogonuser)

EndIf

EndIf

EndIf

EndIf

EndIf

Next result 'O erro acontece aqui....

Grato pela ajuda

 


Viewing all articles
Browse latest Browse all 2

Latest Images





Latest Images