Afficher un message
Vieux 19/09/2007, 17h26   #2
dgob123
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Removing a property in AD via script

Thank you very much...
It works perfectly now!

"Richard Mueller [MVP]" wrote:

>
> "dgob123" <dgob123@discussions.microsoft.com> wrote in message
> news:2793ED2A-D0F1-454D-95E0-FC47F26A098F@microsoft.com...
> >I was tasked with making a web interface to forward emails from users who
> >are
> > absent to users that will be covering them. I have the start forwarding
> > part
> > of it working great, but I am having a problem with telling AD to delete
> > the
> > altRecipient and deliverandRedirect properties to stop the forwarding.
> >
> > Sample Code
> >
> > k = oDict.keys ' cn of users to forward mail from
> > i = oDict.items ' cn of user to forward mail to (NULL is not forward)
> > for s = 0 to oDict.count - 1
> > Set oLDAP = GetObject("LDAP:")
> > 'Response.Write ( k(s) & " --> " & i(s) & "<BR>" )
> > strTargetLdapPath = "LDAP://SVR-SC-002/CN=" & k(s) &
> > ",OU=Operators,OU=CustomerService,OU=Standard,OU=D epartments,OU=LNSP,DC=domain,DC=local"
> > Set oADsTargetContainer = oLDAP.OpenDSObject( strTargetLdapPath,
> > "domain\administrator", "**********", ADS_SERVER_BIND)
> > if i(s) = "NULL" then
> > ' CODE TO DELETE THE PROPERTIES
> > oADsTargetContainer.put "altRecipient", ""
> > oADsTargetContainer.put "deliverandRedirect", ""
> > else
> > ' CODE TO FORWARD THE MAIL
> > oADsTargetContainer.put "altRecipient", "CN=" & i(s) &
> > ",OU=Operators,OU=CustomerService,OU=Standard,OU=D epartments,OU=LNSP,DC=lnsp,DC=com"
> > oADsTargetContainer.put "deliverandRedirect", FALSE
> > end if
> > oADsTargetContainer.SetInfo
> > Next
> > response.Redirect("default.asp")
> >
> > Can some one enlighten me on how to delete these to properties?
> >

>
> You cannot assign a blank string to attribute. To remove the value use the
> PutEx method as follows:
>
> Const ADS_PROPERTY_CLEAR = 1
>
> oADsTargetContainer.PutEx ADS_PROPERTY_CLEAR, "altRecipient", 0
>
> oADsTargetContainer.PutEx ADS_PROPERTY_CLEAR, "deliverandRedirect", 0
>
> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
>

  Réponse avec citation
 
Page generated in 0,07408 seconds with 9 queries