PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.win.server.scripting > Re: Removing a property in AD via script
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Re: Removing a property in AD via script

Réponse
 
LinkBack Outils de la discussion
Vieux 19/09/2007, 14h57   #1
Richard Mueller [MVP]
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Removing a property in AD via script


"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
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
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h06.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16099 seconds with 10 queries