Bonjour,
Je cherche le moyen d'écrire un script VBS pouvant lire dans Active Directory, et se lancant aussi bien sous windows NT/XP que sous windows 98Se
Ceci est dans le but de lire l'appartenance au groupe utilisateur.
Merci
|
|||||||||||
| Le Forum de Référence sur les Technologies Microsoft - http://www.forum-microsoft.org | |||||||||||
Modérateurs: nadir.amghar, Modérateurs_Systèmes


Set wshNetwork = CreateObject("WScript.Network")
Set Sh = CreateObject("WScript.Shell")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName) 
Alban Ponche a écrit:Oui, ca je sais, mais comment. quand je met dans mon script :
- Code: Tout sélectionner
Set wshNetwork = CreateObject("WScript.Network")
Set Sh = CreateObject("WScript.Shell")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))
j'ai une erreur au niveau de la ligne
- Code: Tout sélectionner
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
Sous XP pas de probleme, mais sous 98 il me met : erreur inconnue
Vous pouvez m'aider ??
Active Directory Client Extensions for Windows 95/98 and Windows NT 4.0
Active Directory Features Supported
Windows 95/98-based and Windows NT 4.0-based clients lack many of the features of Windows 2000 Professional that are related to Active Directory. The Active Directory client extension is an upgrade or patch for Windows 95, Windows 98 and Windows NT 4.0, which enables the following Active Directory features:
Active Directory Service Interfaces (ADSI). ADSI allows scripting to Active Directory and provides a common programming API to Active Directory programmers.


ADSysInfo.UserName 

Alban Ponche a écrit:oui enfin le but c pas de passer une variable de DOS vers VB, puisque mon but est de plus avoir de BAT.
Autre suggestion ?
dim wshshell
set wshshell=wscript.createobject("wscript.shell")
Public Sub Debug (str)
'****************
'If (DebugEnable) Then
WScript.Echo "DBG:"& str
'WshShell.LogEvent 1, "DBG:"& WScript.ScriptFullName& ":"& str
'End If
End Sub
dim strcomputername
dim strlogonserver
strcomputername=wshshell.expandenvironmentstrings("%computername%")
strlogonserver=wshshell.expandenvironmentstrings("%logonserver%")
Debug "Init: "& strComputerName
Debug "Init: LogonServer:"& strLogonServer


Alban Ponche a écrit:oui enfin le but c pas de passer une variable de DOS vers VB, puisque mon but est de plus avoir de BAT.
Autre suggestion ?

ExpandEnvironmentStringsSet CurrentUser = GetObject("LDAP://" & username)' Alban Ponche
' 21/05/2005
' Lycée St Jacques Hazebrouck
Const DOMAIN = "toto.com"
Const SERVERNAME = "srv1-pedago"
Const ADMINS98_GROUP= "cn=Admins98"
Const ADMINS_GROUP = "cn=administrateurs"
Const SERVER_UNC = "\\SRV1-PEDAGO"
Set wshNetwork = CreateObject("WScript.Network")
Set Sh = CreateObject("WScript.Shell")
' préparation des variable (pour windows 98)
Set WshSysEnv = Sh.Environment
WScript.Echo "OS = " & WshSysEnv("OS")
WScript.Echo "USER = " & Sh.ExpandEnvironmentStrings("%username%")
If WshSysEnv("OS") = "98" Then
username = Sh.ExpandEnvironmentStrings("%username%")
Set CurrentUser = GetObject("LDAP://" & username)
Else
Set objadsi = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & objadsi.UserName)
End If
strGroups = LCase(Join(CurrentUser.MemberOf))
' Mappage des lecteurs réseau pour le groupe Administrateurs
If InStr(strGroups,ADMINS_GROUP) Or InStr(strGroups,ADMINS_GROUP) Then
wshNetwork.MapNetworkDrive "g:", SERVER_UNC & "\Distribution"
wshNetwork.MapNetworkDrive "h:", SERVER_UNC & "\Dossiers"
wshNetwork.MapNetworkDrive "i:", SERVER_UNC & "\Dossiers\administration"
wshNetwork.MapNetworkDrive "j:", SERVER_UNC & "\Dossiers\rep_base"
End If


Utilisateurs parcourant actuellement ce forum : Aucun utilisateur inscrit et 0 invités