Get users principal names

Is there a possible way to somehow extract users principal names by a given pattern? or somehow check the uniqueness of the UPN in targeted ADDS. Any suggestions would be appreciated!

like it happened in script VI_AE_BuildCentralAccountGlobalUnique:

'fill existing addresses in a list
Dim existing As New List(Of String)
Dim dummy As New Object()
Dim dummyPerson As ISingleDbObject
dummyPerson = Connection.CreateSingle("Person")
Dim pattern As String = "%" & Lastname & "%"
Dim myObjectKey As New DbObjectKey("Person", uid_person)
Dim accountName As String
Dim objectKeyString As String
Dim objectKey As DbObjectKey

Using rd As IDataReader = CType(dummyPerson.Custom.CallMethod("SearchCentralAccount", pattern), IDataReader)

While rd.Read()

accountName = rd.GetString(rd.GetOrdinal("AccountName"))
objectKeyString = rd.GetString(rd.GetOrdinal("ObjectKeyPerson"))

If Not String.IsNullOrEmpty(objectKeyString) Then
objectKey = New DbObjectKey(objectKeyString)

'only addresses which not belong to the actual employee will be considered
If myObjectKey.Equals(objectKey) Then
Continue While
End If
End If

existing.Add(accountName)
End While
End Using