472,965 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Get Telephone-Number from Active Directory

1
I am trying to retrieve the telephone_number from active directory using the following script:

Dim search As New DirectorySearcher("")

search.Filter = "(&(objectCategory=Person)(objectClass=user)(!(use rAccountControl:1.2.840.113556.1.4.803:=2))(samacc ountname=" + UserName.ToString.Trim + "))"
'search.Filter = "(&(!(userAccountControl:1.2.840.113556.1.4.803:=2 ))( objectCategory=person)(samaccountname=" + UserName.ToString.Trim + "))"
search.PropertiesToLoad.Add("samaccountname")
search.PropertiesToLoad.Add("sn")
search.PropertiesToLoad.Add("givenname")
search.PropertiesToLoad.Add("mail")
search.PropertiesToLoad.Add("physicaldeliveryoffic ename")
search.PropertiesToLoad.Add("Telephone-Number")

Dim result As SearchResult = search.FindOne()

If Not (IsNothing(result)) Then
Try
Dim myResultPropColl As ResultPropertyCollection
myResultPropColl = result.Properties

Dim myKey As String
For Each myKey In myResultPropColl.PropertyNames
Select Case myKey
Case "samaccountname"
Try
UserName = myResultPropColl(myKey)(0)

Catch ex As Exception
UserName = ""

End Try
Case "sn"
Try
SurName = myResultPropColl(myKey)(0)

Catch ex As Exception
SurName = ""

End Try
Case "givenname"
Try
FirstName = myResultPropColl(myKey)(0)

Catch ex As Exception
FirstName = ""

End Try
Case "mail"
Try
Email = myResultPropColl(myKey)(0)

Catch ex As Exception
Email = ""

End Try
Case "Telephone-Number"
Try
Phone = myResultPropColl(myKey)(0)

Catch ex As Exception
Phone = ""

End Try
Case "physicaldeliveryofficename"
Try
Office = myResultPropColl(myKey)(0)

Catch ex As Exception
Office = ""
End Try
End Select
Next
If Email <> "" Then
DatatoWrite = InUserName & "|" & UserName & "|" & SurName & "|" & FirstName & "|" & Email & "|" & Phone & "|" & newnumber & "|" & Office & "|" & newoffice
End If

Catch ex As Exception
errcount = errcount + 1
DatatoWrite = InUserName & "| UserID Not Found "
End Try
Else
errcount = errcount + 1
DatatoWrite = InUserName & "| UserID Not Found "

End If

I get all the data EXCEPT Telephone-Number

UserName if provided via an input file

Any help will be greatly appreciated
Aug 31 '08 #1
0 2819

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

Similar topics

0
by: Cesare Nicolai C. | last post by:
Hi! Someone knows if using only MIDP1.0 to program an application, these last works on all the cellular ones that support such profile? Moreover the same application can wark on a telephone gprs...
383
by: John Bailo | last post by:
The war of the OSes was won a long time ago. Unix has always been, and will continue to be, the Server OS in the form of Linux. Microsoft struggled mightily to win that battle -- creating a...
0
by: Ike | last post by:
Ive been asked to write an application that can discern what numbers have been dialed on a telephone. I know nothing of this, except that there is some sort of hardware that can do an INSET to a...
0
by: BizTalk Architect | last post by:
Hello, C# + TAPI Anyone know a routine which will query the local TAPI provider for all available telephone numbers for a call to be transfered to? Thanks....
0
by: Mark | last post by:
Hello, How can I make some telephone app in VB.NET> I want make leaving machine. Thank foe answers.
0
by: Don Quijote de Nicaragua | last post by:
Hi guys, I just wanted to ask you about how to record information from an IP telephone. I have a cyber cafe and my supplier only provides reports in HTML format. Is there any way to record the...
1
by: Ed Dror | last post by:
Hi there, I have Access database with telephone column and When I created a webform data grid With VWD 2005 this column show like this 5552223333 how do I format it like (555)222-3333 ...
10
by: Nkhosinathie | last post by:
This isn't a homework,i want to improve my skills in programming and apply my understanding to pinters. i'm developing a program that will print telephone numbers randomly for a city for...
3
by: Smythe32 | last post by:
Hi, I am in need of some assistance. I have a table with the following: Tel_St_Range Tel_End_Range Customer Name 6075551200 6075551300 Tom Smith I would like to know how to...
5
by: rikigr4 | last post by:
Hi All, I am looking for code written in .NET that provides connection between application and telephone. So that - the telephone will return a code according to input code that it get's from the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.