#92232 - 2003-06-2307:09 AMHow do you create blank fields with ADSI on AD
NTDOCNTDOC Administrator
Registered: 2000-07-28
Posts: 11628
Loc: CA
I ran accross this the other day and so far have not found a solution. I'm sure it can easily be done once you know the correct syntax or method.
I had a lot of accounts in the Active Directory that had some invalid data on their ProfilePath
It is easy to query or update data on the Active Directory, but I could not figure out how to delete the entry and leave it blank.
Example:
$UserGroup = GetObject('LDAP://etc...')
for each $user in $UserGroup
if $user.class = "user" if NOT $user.profilePath ="" ? 'Profile path for '+$user.name+ 'is not blank - it is: '+$user.profilepath
$user.profilePath="" $user.SetInfo
endif
endif
next
The user profile will not be set to blank.
I can run this code and it works fine.
$UserGroup = GetObject('LDAP://etc...')
for each $user in $UserGroup
if $user.class = "user" if NOT $user.profilePath ="" ? 'Profile path for '+$user.name+ 'is not blank - it is: '+$user.profilepath
$user.profilePath="Anything I want it to be except BLANK" $user.SetInfo
endif
endif
next
I found this to be true for other fields as well, which leads me to believe that there must be some special syntax, or method to accomplish a BLANK entry or Delete (without replacing) and entry.
You can create/delete to have a BLANK entry with the GUI tools, so I know it can be done.
Does anyone know the proper method to BLANK/DELETE an entry?
#92236 - 2003-06-2308:15 PMRe: How do you create blank fields with ADSI on AD
Chris S.Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
Doc, I was just going to post a translation for you. You beat me to it.
Oh, well. At least I can help you with the Filter. Take a peek at this...
Dim $sFilter[0] $sFilter[0]="User" $UserGroup = GetObject('LDAP://blah...') $UserGroup.Filter = $sFilter For Each $User in $UserGroup If Not $User.profilePath ="" 'Old ProfilePath for '+$User.Name+': '+$User.profilePath+"*" ? $user.PutEx (1,"profilePath","") ;$user.profilePath="test" $user.SetInfo 'New ProfilePath for '+$User.Name+': '+$User.profilePath+"*" ? EndIf Next
[ 23. June 2003, 20:28: Message edited by: Chris S. ]
Greetings! I don't mean to bump an old thread, but this is exactly what I was looking for to reset some of my data as well.
But, with one exception. I also need to empty out some arrays.
This is what I tried knowing that it wouldn't work.
For Each $Element In $user.msExchADCGlobalNames If Not $Element ="" ? $Element $user.PutEx(1,$user.msExchADCGlobalNames,"") ? $User.Name + " ADCG cleared." $user.Setinfo endif Next
For Each $Element In $user.msExchADCGlobalNames If Not $Element ="" $Element.PutEx (1,"msExchADCGlobalNames","") ? $User.Name + " ADCG cleared." $user.Setinfo/ endif Next
Dim $sFilter[0] $sFilter[0]="User" $UserGroup = GetObject('LDAP://cn=Users,dc=xxx,dc=com') $UserGroup.Filter = $sFilter For Each $User in $UserGroup If Not $User.msExchADC ="" $user.PutEx (1,"legacyExchangeDN","") ? $User.Name + " ExDN cleared." $user.Setinfo endif
If Not $User.mail ="" $user.PutEx (1,"mail","") ? $User.Name + " mail cleared." $user.Setinfo endif
For Each $Element In $user.msExchADCGlobalNames If Not $Element ="" $user.PutEx(1,"msExchADCGlobalNames","") ? $User.Name + " ADCG cleared." $user.Setinfo/ endif Next
next
I'm trying to clean up a bad ADC replication, and I need to set msExchADCGlobalNames to empty.
Dim $sFilter[0] $sFilter[0]="User" $UserGroup = GetObject('LDAP://cn=Users,dc=xxx,dc=com') $UserGroup.Filter = $sFilter For Each $User in $UserGroup If Not $User.msExchADC ="" $user.PutEx (1,"legacyExchangeDN","") ? $User.Name + " ExDN cleared." $user.Setinfo endif
If Not $User.mail ="" $user.PutEx (1,"mail","") ? $User.Name + " mail cleared." $user.Setinfo endif
For Each $Element In $user.msExchADCGlobalNames If Not $Element ="" $user.PutEx(1,"msExchADCGlobalNames","") ? $User.Name + " ADCG cleared." $user.Setinfo endif Next
next
I'm trying to clean up a bad ADC replication, and I need to set msExchADCGlobalNames to empty.
Your last post worked, I'm testing again.
[ 23. July 2003, 19:20: Message edited by: Jason Gauthier ]