Click here to Skip to main content
15,895,746 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionHow to get machine certificate and user license. Pin
deadlyabbas12-May-09 21:01
deadlyabbas12-May-09 21:01 
Question.Net Remoting with COM client Pin
lee2312-May-09 19:43
lee2312-May-09 19:43 
Questionproblem with richedit control [modified] Pin
ramaluciano12-May-09 18:52
ramaluciano12-May-09 18:52 
QuestionIRunningObjectTable.Register method Pin
lee2312-May-09 18:23
lee2312-May-09 18:23 
AnswerRe: IRunningObjectTable.Register method Pin
lee2312-May-09 19:06
lee2312-May-09 19:06 
GeneralRe: IRunningObjectTable.Register method Pin
lee2313-May-09 20:25
lee2313-May-09 20:25 
QuestionSeeking advice for storing data in memory [modified] Pin
glumlord12-May-09 7:46
glumlord12-May-09 7:46 
AnswerRe: Seeking advice for storing data in memory Pin
glumlord12-May-09 7:59
glumlord12-May-09 7:59 
Imports System.IO
Imports System.DirectoryServices
Imports System.Data


Module Module1

    Public dsCSIDir As New DataSet("CSIDIR")
    Public Users_Table As New DataTable
    Public drUser As DataRow

    Sub ImportUsers()
        Dim direntry As New DirectoryEntry("LDAP://OU=CSI Users, DC=csileasing, DC=com")
        Dim searcher As New DirectorySearcher(direntry)

        Dim i As Integer = 0
        Dim result As SearchResult
        Console.WriteLine("Started Data Import at :  " & TimeOfDay)
        Try
            searcher.Filter = "(&(objectClass=user)(samaccountname=*))"
            searcher.ClientTimeout = TimeSpan.FromSeconds(5)

            For Each result In searcher.FindAll
                If result.Properties("samaccountname")(0) = Nothing Then
                    Continue For
                End If

                drUser = Users_Table.NewRow

                drUser("index") = i

                If result.Properties.Contains("company") Then
                    drUser("Company") = result.GetDirectoryEntry.Properties("company").Value
                Else
                    Continue For
                End If

                drUser("LoginID") = result.GetDirectoryEntry.Properties("samaccountname").Value
                drUser("DisplayName") = result.GetDirectoryEntry.Properties("cn").Value

                If result.Properties.Contains("title") Then
                    drUser("Title") = result.GetDirectoryEntry.Properties("title").Value
                End If

                If result.Properties.Contains("telephoneNumber") Then
                    drUser("OfficePhone") = result.GetDirectoryEntry.Properties("telephoneNumber").Value
                End If

                If result.Properties.Contains("mobile") Then
                    drUser("CellPhone") = result.GetDirectoryEntry.Properties("mobile").Value
                End If

                If result.Properties.Contains("mail") Then
                    drUser("Email") = result.GetDirectoryEntry.Properties("mail").Value
                End If

                If result.Properties.Contains("streetAddress") Then
                    drUser("Street") = result.GetDirectoryEntry.Properties("streetAddress").Value
                End If

                If result.Properties.Contains("l") Then
                    drUser("City") = result.GetDirectoryEntry.Properties("l").Value
                End If

                If result.Properties.Contains("st") Then
                    drUser("State") = result.GetDirectoryEntry.Properties("st").Value
                End If

                If result.Properties.Contains("postalCode") Then
                    drUser("PostalCode") = result.GetDirectoryEntry.Properties("postalCode").Value
                End If

                If result.Properties.Contains("memberof") Then
                    Dim groups As DirectoryServices.ResultPropertyValueCollection = result.Properties.Item("MemberOf")
                    Dim groupslist As String = ""
                    Dim groupname As String = ""
                    For k As Int16 = 0 To groups.Count - 1
                        Dim fullname As String = result.Properties("memberof").Item(k).ToString
                        groupname = Left(Split(fullname, "=")(1), Len(Split(fullname, "=")(1)) - 3)
                        groupslist = groupslist & groupname & ","
                    Next
                    groupslist = Left(groupslist, Len(groupslist) - 1)
                    drUser("Groups") = groupslist
                End If

                If result.Properties.Contains("manager") Then
                    Dim managername As String() = Split(result.Properties("manager")(0), ",")
                    drUser("Manager") = Right(managername(0), Len(managername(0)) - 3)
                End If

                If result.Properties.Contains("sn") Then
                    drUser("FirstName") = result.GetDirectoryEntry.Properties("sn").Value
                End If

                If result.Properties.Contains("givenname") Then
                    drUser("LastName") = result.GetDirectoryEntry.Properties("givenname").Value
                End If

                If result.Properties.Contains("directReports") Then
                    Dim groups As DirectoryServices.ResultPropertyValueCollection = result.Properties.Item("directReports")
                    Dim groupslist As String = ""
                    Dim groupname As String = ""
                    For k As Int16 = 0 To groups.Count - 1
                        Dim fullname As String = result.Properties("directReports").Item(k).ToString
                        groupname = Left(Split(fullname, "=")(1), Len(Split(fullname, "=")(1)) - 3)
                        groupslist = groupslist & groupname & ","
                    Next
                    groupslist = Left(groupslist, Len(groupslist) - 1)
                    drUser("DirectReports") = groupslist
                End If

                If result.Properties.Contains("department") Then
                    drUser("Department") = result.GetDirectoryEntry.Properties("department").Value
                End If
                i += 1
                Users_Table.Rows.Add(drUser)
            Next
        Catch ex As Exception

        End Try
        Users_Table.AcceptChanges()
        dsCSIDir.Tables.Add(Users_Table)
    End Sub

    Public Sub CreateDataStructure()
        Users_Table.TableName = "Users"
        Console.WriteLine("Start of Create Columns at:  " & TimeOfDay)
        Users_Table.Columns.Add("index", GetType(Integer))
        Users_Table.Columns.Add("LoginID", GetType(String))
        Users_Table.Columns.Add("FirstName", GetType(String))
        Users_Table.Columns.Add("LastName", GetType(String))
        Users_Table.Columns.Add("DisplayName", GetType(String))
        Users_Table.Columns.Add("Title", GetType(String))
        Users_Table.Columns.Add("Company", GetType(String))
        Users_Table.Columns.Add("Email", GetType(String))
        Users_Table.Columns.Add("OfficePhone", GetType(String))
        Users_Table.Columns.Add("CellPhone", GetType(String))
        Users_Table.Columns.Add("Street", GetType(String))
        Users_Table.Columns.Add("City", GetType(String))
        Users_Table.Columns.Add("State", GetType(String))
        Users_Table.Columns.Add("PostalCode", GetType(String))
        Users_Table.Columns.Add("Manager", GetType(String))
        Users_Table.Columns.Add("Department", GetType(String))
        Users_Table.Columns.Add("Groups", GetType(String))
        Users_Table.Columns.Add("DirectReports", GetType(String))
        Console.WriteLine("End of Create Columns at:  " & TimeOfDay)
    End Sub

AnswerRe: Seeking advice for storing data in memory Pin
Ian McCaul12-May-09 8:32
Ian McCaul12-May-09 8:32 
GeneralRe: Seeking advice for storing data in memory Pin
glumlord12-May-09 8:37
glumlord12-May-09 8:37 
GeneralRe: Seeking advice for storing data in memory Pin
Ian McCaul12-May-09 8:43
Ian McCaul12-May-09 8:43 
GeneralRe: Seeking advice for storing data in memory Pin
glumlord12-May-09 9:26
glumlord12-May-09 9:26 
GeneralRe: Seeking advice for storing data in memory Pin
jarbo3a12-May-09 20:13
jarbo3a12-May-09 20:13 
GeneralRe: Seeking advice for storing data in memory Pin
glumlord13-May-09 7:35
glumlord13-May-09 7:35 
AnswerRe: Seeking advice for storing data in memory Pin
Dave Kreskowiak12-May-09 8:43
mveDave Kreskowiak12-May-09 8:43 
GeneralRe: Seeking advice for storing data in memory Pin
glumlord12-May-09 9:24
glumlord12-May-09 9:24 
GeneralRe: Seeking advice for storing data in memory Pin
Dave Kreskowiak12-May-09 11:01
mveDave Kreskowiak12-May-09 11:01 
GeneralRe: Seeking advice for storing data in memory Pin
Luc Pattyn12-May-09 9:45
sitebuilderLuc Pattyn12-May-09 9:45 
GeneralRe: Seeking advice for storing data in memory Pin
Dave Kreskowiak12-May-09 10:57
mveDave Kreskowiak12-May-09 10:57 
GeneralRe: Seeking advice for storing data in memory Pin
Luc Pattyn12-May-09 13:54
sitebuilderLuc Pattyn12-May-09 13:54 
GeneralRe: Seeking advice for storing data in memory Pin
Dave Kreskowiak12-May-09 16:12
mveDave Kreskowiak12-May-09 16:12 
GeneralRe: Seeking advice for storing data in memory Pin
glumlord13-May-09 7:30
glumlord13-May-09 7:30 
QuestionUnable to run the code from sp1 in sp2 Pin
SuchiTN12-May-09 4:06
SuchiTN12-May-09 4:06 
AnswerRe: Unable to run the code from sp1 in sp2 Pin
Pete O'Hanlon12-May-09 4:20
mvePete O'Hanlon12-May-09 4:20 
AnswerRe: Unable to run the code from sp1 in sp2 Pin
Luc Pattyn12-May-09 4:39
sitebuilderLuc Pattyn12-May-09 4:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.