473,786 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get Telephone-Number from Active Directory

1 New Member
I am trying to retrieve the telephone_numbe r from active directory using the following script:

Dim search As New DirectorySearch er("")

search.Filter = "(&(objectCateg ory=Person)(obj ectClass=user)( !(userAccountCo ntrol:1.2.840.1 13556.1.4.803:= 2))(samaccountn ame=" + UserName.ToStri ng.Trim + "))"
'search.Filter = "(&(!(userAccou ntControl:1.2.8 40.113556.1.4.8 03:=2))( objectCategory= person)(samacco untname=" + UserName.ToStri ng.Trim + "))"
search.Properti esToLoad.Add("s amaccountname")
search.Properti esToLoad.Add("s n")
search.Properti esToLoad.Add("g ivenname")
search.Properti esToLoad.Add("m ail")
search.Properti esToLoad.Add("p hysicaldelivery officename")
search.Properti esToLoad.Add("T elephone-Number")

Dim result As SearchResult = search.FindOne( )

If Not (IsNothing(resu lt)) Then
Try
Dim myResultPropCol l As ResultPropertyC ollection
myResultPropCol l = result.Properti es

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

Catch ex As Exception
UserName = ""

End Try
Case "sn"
Try
SurName = myResultPropCol l(myKey)(0)

Catch ex As Exception
SurName = ""

End Try
Case "givenname"
Try
FirstName = myResultPropCol l(myKey)(0)

Catch ex As Exception
FirstName = ""

End Try
Case "mail"
Try
Email = myResultPropCol l(myKey)(0)

Catch ex As Exception
Email = ""

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

Catch ex As Exception
Phone = ""

End Try
Case "physicaldelive ryofficename"
Try
Office = myResultPropCol l(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 2865

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

Similar topics

0
1404
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 and umts or can arise problems (for example connected to the band.)? Thanks, Cesar
383
12258
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 poor man's DBMS, a broken email server and various other /application/ servers to try and crack the Internet and IS markets. In the case where they didn't spend their own money to get companies to
0
1303
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 MySQL database somehow. Has anyone ever heard of such a creature? -Ike
0
1479
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
927
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
857
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 beginning and ending of a phone call and receive the basic information about that phone call, such as the time and the country to which the call was made so that I can manipulate the data in VB.NET. Gracias. Don Quijote de Nicaragua.
1
1144
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 Thanks, Ed Dror
10
2461
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 instance(maybe use a code for (011) and those telephone numbers should be equal to 10 numbers. so may someone please give a clue how to start this beautiful thinking of mine.thanks
3
1562
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 break out the ranges into a new table that looks like this: Telephone Customer Name 6075551200 Tom Smith
5
6181
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 user. I'll be happy to get even a little help - if you know something that relate and can help me!! Thanks. http://www.codeproject.com/script/Forums/Images/smiley_wink.gif http://www.codeproject.com/script/Forums/Images/smiley_confused.gif
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9961
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8989
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4066
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.