setInfo

setInfo - VB/VBA/VBS - Programmation

Marsh Posté le 24-03-2005 à 18:42:17    

Bonjour,
Je viens d'écrire un bout de code pour créer des utilisateurs dans Active Directory dans une OU que je créé également.
Je n'arrive pas à corriger l'erreur suivante :
 
L’opération demandée n’est pas compatible avec l’une ou plusieurs des contraintes associées avec la classe
Code 80072014
Source null
 
L'erreur se génère à la dernière instruction : adsUser.SetInfo
J'ai plcé un commentaire dans le source ci-dessous.
 
Je voudrais vous signaler que je débute dans la programmation.
Par avance je vous remercie.
 
Voici le source :  
 
DIM arrRecord
Const ForReading = 1
Const OU1 = "OU=WinNG"
Const OU2 = "OU=Utilisateurs"
 
Set Root = GetObject("LDAP://RootDSE" )
DomainPath = Root.Get("DefaultNamingContext" )
 
Set Domain = GetObject("LDAP://" & DomainPath)
 
Set ou_HR = Domain.Create("organizationalUnit", OU1)
ou_HR.Put "Description", "Windows Nouvelle Génération"
ou_HR.SetInfo
 
Set Domain2 = GetObject("LDAP://" & OU1 & "," & DomainPath)
 
Set OU_Ut = Domain2.create("organizationalUnit", OU2)
OU_Ut.SetInfo
 
set fso = CreateObject ("Scripting.FileSystemObject" )
 
Set tsTextFile = fso.OpenTextFile ("C:\travail\utils.txt", ForReading, False)
 
While Not tsTextFile.AtEndOfStream
 
 strRecord = tsTextFile.ReadLine
 
 arrRecord = Split (strRecord, ":" )
 Set adsUser = OU_Ut.Create("user", "CN=" & arrRecord(0))
 
 adsUser.Put "sAMAccountName",  arrRecord(0)
 adsUser.Put "userPrincipalName", arrRecord(0)
 adsUser.SetInfo
 
 adsUser.AccountDisabled = False
 adsUser.givenName = arrRecord(1)    'prénom
 adsUser.initials = arrRecord(2)     'initiale
 adsUser.sn = arrRecord(3)           'nom
 adsUser.DisplayName = arrRecord(4)  'nom affiché
 adsUser.description = arrRecord(5)  'description
 adsUser.Wwwhomepage = arrRecord(6)  'page Web
 adsUser.SetPassword "P@ssw0rd"      'mot de passe
 
set grp = GetObject("LDAP://CN=Administrateurs de l'entreprise,CN=Users,"&DomainPath)
grp.Add "LDAP://CN="&arrRecord(0)&"," & OU2 & "," & OU1 & "," &DomainPath
set grp = GetObject("LDAP://CN=Administrateurs,CN=Builtin,"&DomainPath)
grp.Add "LDAP://CN="&arrRecord(0)&"," & OU2 & "," & OU1 & "," &DomainPath
set grp = GetObject("LDAP://CN=Admins du domaine,CN=Users,"&DomainPath)  
grp.Add "LDAP://CN="&arrRecord(0)&"," & OU2 & "," & OU1 & "," &DomainPath
 
''''''''''''''''''''
'L'ERREUR EST ICI
''''''''''''''''''''
 
 adsUser.SetInfo
 
 Set adsUser = Nothing
 
Wend                                    
tsTextFile.Close

Reply

Marsh Posté le 24-03-2005 à 18:42:17   

Reply

Marsh Posté le 07-04-2005 à 13:03:06    

edit : j'ai dit une connerie chez moi ton code passe sans probleme


Message édité par snipe le 07-04-2005 à 14:07:17

---------------
Feed-back
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed