If I have a string value equal to "Firstname Lastname" and I want to separate the two into their own separate variables, how can i do that? i think i will need to use an instr to find the " " but I'm not sure what to do after that. I'm using the faq on access the active directory to get the full name of the user. I have this in a function call that is returning the full name:
Public Function GetUserInfo(ByVal domain As String, ByVal username As String, ByVal pwd As String) As String
Dim domainAndUsername As String = domain & "\" & username
Dim entry As DirectoryEntry = New DirectoryEntry(_path, domainAndUsername, pwd)
Dim strRealName As String
Dim Searcher As DirectorySearcher = New DirectorySearcher(entry)
Dim result As System.DirectoryServices.SearchResult
Try
Searcher.Filter = ("(anr=" & username & ")")
result = Searcher.FindOne()
strRealName = result.Properties("givenName")(0).ToString() & " " & result.Properties("sn")(0).ToString()
Catch ex As Exception
Debug.Write(ex.Message)
End Try
Return strRealName
End Function
can i get the function to return two separate values? or will i have to get it to return the full name and then separate it later?
Public Function GetUserInfo(ByVal domain As String, ByVal username As String, ByVal pwd As String) As String
Dim domainAndUsername As String = domain & "\" & username
Dim entry As DirectoryEntry = New DirectoryEntry(_path, domainAndUsername, pwd)
Dim strRealName As String
Dim Searcher As DirectorySearcher = New DirectorySearcher(entry)
Dim result As System.DirectoryServices.SearchResult
Try
Searcher.Filter = ("(anr=" & username & ")")
result = Searcher.FindOne()
strRealName = result.Properties("givenName")(0).ToString() & " " & result.Properties("sn")(0).ToString()
Catch ex As Exception
Debug.Write(ex.Message)
End Try
Return strRealName
End Function
can i get the function to return two separate values? or will i have to get it to return the full name and then separate it later?