473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Identifying empty Active Directory attributes

Hi

I am trying to extract user data from Active Directory and locate it in an
offline Access database for reporting. The problem I have is when I came
acrsoss an object where an attribute is empty.

I tried to trap this with an isDBnull call (as below) but this does not
work - is it possible to identify null attributes in an Active Directory
SearchResult?

Ta PP

Dim ResEnt As SearchResultCollection = mySearcher.FindAll()

' Iterate through each SearchResult in the SearchResultCollection.

Dim resEnt1 As SearchResult

For Each resEnt1 In ResEnt

If IsDBNull(resEnt1.Properties("company")) Then

valueCompany = NoValueString

Else

valueCompany = resEnt1.Properties("company").ToString

'valueCompany = CStr(resEnt1.Properties("company")(0))

End If

Feb 12 '08 #1
1 3877
Here is what I use to extract AD properties so it does not produce any
problems. I hope you find it useful.

Private Shared Function ExtractADPropertyValue(ByVal propertyName As
String, ByVal result As System.DirectoryServices.SearchResult) As String

Dim propertyValue As String = String.Empty

If result.Properties.Contains(propertyName) Then
propertyValue = result.Properties(propertyName).Item(0).ToString()
End If

Return propertyValue

End Function

======================================
David McCarter [Microsoft MVP]
www.dotNetTips.com
David McCarter''''s .NET Coding Standards available at:
http://www.cafepress.com/geekmusicart.1654787045
"Pete Piper" wrote:
Hi

I am trying to extract user data from Active Directory and locate it in an
offline Access database for reporting. The problem I have is when I came
acrsoss an object where an attribute is empty.

I tried to trap this with an isDBnull call (as below) but this does not
work - is it possible to identify null attributes in an Active Directory
SearchResult?

Ta PP

Dim ResEnt As SearchResultCollection = mySearcher.FindAll()

' Iterate through each SearchResult in the SearchResultCollection.

Dim resEnt1 As SearchResult

For Each resEnt1 In ResEnt

If IsDBNull(resEnt1.Properties("company")) Then

valueCompany = NoValueString

Else

valueCompany = resEnt1.Properties("company").ToString

'valueCompany = CStr(resEnt1.Properties("company")(0))

End If

Feb 14 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
3
by: tornado | last post by:
Hi all, I am pretty new to PHP. I was reading PHP manual and trying out the example from 2nd chapter (A simple Tutorial). When i try to print the variable as given in the example it returns...
6
by: Tung Wai Yip | last post by:
Can I add empty directory using zipfile? When I try to add a directory it complains that it is not a file. tung
4
by: Brandon Arnold | last post by:
Hello All, I have a linked ADSI Server to our company Active Directory and everything is fine. I'm running queries and such using LDAP. BUT how can I aquire a list of attributes for the classes...
9
by: Mario Rodriguez | last post by:
Hi people. I have a problem adding users to Win2003 active directory programatically. When I execute my app throws the following exception: .................The specified directory service...
13
by: could ildg | last post by:
I want to check if a folder named "foldername" is empty. I use os.listdir(foldername)== to do this, but it will be very slow if the folder has a lot of sub-files. Is there any efficient ways to do...
4
by: Dave | last post by:
Hello. I am trying to update attributes in LDAP/Active directory from my application that is written in VB.NET. I am using Directory Services to do so. I do not get any errors during the...
1
by: Keith Jakobs, MCP | last post by:
HELP!!!! VB.NET has been a thorn in my side, but trying to use the System.DirectoryServices namespace has to be one of the most ridiculously confusing classes I have EVER encountered!!!! Am I...
5
by: Tom P. | last post by:
I am having the following problem: I create a FileSystemWatcher and wait for events. When the event does happen I refresh a FileSystemInfo list and set properties accordingly (IsFile, IsDir,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.