By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,212 Members | 1,093 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,212 IT Pros & Developers. It's quick & easy.

Set Active Directory 'company' value to NULL??

P: n/a
Hi!

Is it possible to set the value of an Active Directory attribute to be
empty?

I've tried to set the 'company' attribute as follows:
myRepEntry.Properties(strAttrName)(0) = Nothing

but I get an error stating that the value cannot be NULL.

Anyone got any ideas?

Thanks for your help!

Phil
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Download microsofts ADSI Scriptomatic, look the at examples for SetEx, the
concept is the same.
Jared

"Phil Kelly" <ph********@infatech.com> wrote in message
news:cb**********@sparta.btinternet.com...
Hi!

Is it possible to set the value of an Active Directory attribute to be
empty?

I've tried to set the 'company' attribute as follows:
myRepEntry.Properties(strAttrName)(0) = Nothing

but I get an error stating that the value cannot be NULL.

Anyone got any ideas?

Thanks for your help!

Phil

Nov 20 '05 #2

P: n/a
Sorry, I mean PutEx ,not SetEx

"Phil Kelly" <ph********@infatech.com> wrote in message
news:cb**********@sparta.btinternet.com...
Hi!

Is it possible to set the value of an Active Directory attribute to be
empty?

I've tried to set the 'company' attribute as follows:
myRepEntry.Properties(strAttrName)(0) = Nothing

but I get an error stating that the value cannot be NULL.

Anyone got any ideas?

Thanks for your help!

Phil

Nov 20 '05 #3

P: n/a
But surely that's using ADSI when I'm in vb - why can I not simply use:
myRepEntry.Properties(strAttrName)(0) = vbNull
If I pass the value "company" to the variable straAttrName.... surely that
should work. Or am I being stupid???

"Jared" <VB***********@email.com> wrote in message
news:10*************@corp.supernews.com...
Sorry, I mean PutEx ,not SetEx

"Phil Kelly" <ph********@infatech.com> wrote in message
news:cb**********@sparta.btinternet.com...
Hi!

Is it possible to set the value of an Active Directory attribute to be
empty?

I've tried to set the 'company' attribute as follows:
myRepEntry.Properties(strAttrName)(0) = Nothing

but I get an error stating that the value cannot be NULL.

Anyone got any ideas?

Thanks for your help!

Phil


Nov 20 '05 #4

P: n/a
Phil,
I have to say that I have never tried to clear a value using .Net, most of
the time I just write a quick script so I was unsure of the actual outcome.
I created a simple project in which I directly set the value and it works
fine.

First, on single valued fields, just set the property value and commit.
'Check ADSIEdit value should appear as <not set>
myRepEntry.Properties("company").Value = vbNullString
myRepEntry.CommitChanges

On muitivalued fields you need to create a new system.array object and
remove the items you don't want to include or set the value to vbNullString
to clear evertying.

Secondly, if you know the attribute can only contain a single value why
specify the index?
myRepEntry.Properties(strAttrName)(0) vs.
myRepEntry.Properties(strAttrName).Value

You can test to see if the attribute is multivalued by checking the value
against system.array, I think that a multivalued attribute that has only a
single value specified is stored as a string and not an array but I'm not
sure.

If TypeOf Entry.Properties("otherHomePhone").Value Is System.Array Then
Dim PhoneNumbers As System.Array =
Entry.Properties("otherHomePhone").Value
Else
Dim PhoneNumber as String = Entry.Properties("otherHomePhone").Value
End If

"Phil Kelly" <ph********@infatech.com> wrote in message
news:cb**********@sparta.btinternet.com...
But surely that's using ADSI when I'm in vb - why can I not simply use:
myRepEntry.Properties(strAttrName)(0) = vbNull
If I pass the value "company" to the variable straAttrName.... surely that
should work. Or am I being stupid???

"Jared" <VB***********@email.com> wrote in message
news:10*************@corp.supernews.com...
Sorry, I mean PutEx ,not SetEx

"Phil Kelly" <ph********@infatech.com> wrote in message
news:cb**********@sparta.btinternet.com...
> Hi!
>
> Is it possible to set the value of an Active Directory attribute to be
> empty?
>
> I've tried to set the 'company' attribute as follows:
> myRepEntry.Properties(strAttrName)(0) = Nothing
>
> but I get an error stating that the value cannot be NULL.
>
> Anyone got any ideas?
>
> Thanks for your help!
>
> Phil
>
>
>



Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.