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 > Require a User to Logon on Using a Smartcard Script
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Require a User to Logon on Using a Smartcard Script

Réponse
 
LinkBack Outils de la discussion
Vieux 30/08/2007, 15h44   #1
Noah382
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Require a User to Logon on Using a Smartcard Script

Hello All,

I am trying to run a script on multiple users, but the script example given
by Microsoft is only good for an individual user account.
HEre is the script example:
Const ADS_UF_SMARTCARD_REQUIRED = &h40000

Set objUser = GetObject _
("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com" )

intUAC = objUser.Get("userAccountControl")

If (intUAC AND ADS_UF_SMARTCARD_REQUIRED) = 0 Then
objUser.Put "userAccountControl", intUAC XOR ADS_UF_SMARTCARD_REQUIRED
objUser.SetInfo
End If


What I am trying to do is run this script on a define OU which will enable
smart card login for ALL of the users in that OU. This script only defines
one specific user. Any would be appreciated.

Thanks

Noah
  Réponse avec citation
Vieux 30/08/2007, 16h45   #2
Richard Mueller [MVP]
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Require a User to Logon on Using a Smartcard Script

Noah wrote:

> I am trying to run a script on multiple users, but the script example
> given
> by Microsoft is only good for an individual user account.
> HEre is the script example:
> Const ADS_UF_SMARTCARD_REQUIRED = &h40000
>
> Set objUser = GetObject _
> ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com" )
>
> intUAC = objUser.Get("userAccountControl")
>
> If (intUAC AND ADS_UF_SMARTCARD_REQUIRED) = 0 Then
> objUser.Put "userAccountControl", intUAC XOR ADS_UF_SMARTCARD_REQUIRED
> objUser.SetInfo
> End If
>
>
> What I am trying to do is run this script on a define OU which will enable
> smart card login for ALL of the users in that OU. This script only defines
> one specific user. Any would be appreciated.


Enclose the snippet above in a loop that enumerates all users in the OU.
============
Option Explicit
Dim objOU, objUser, intUAC
Const ADS_UF_SMARTCARD_REQUIRED = &h40000

' Bind to the OU using its Distinguished Name.
Set objOU = GetObject("LDAP://ou=West,dc=MyDomain,dc=com")

' Filter on user objects.
' This includes computer objects.
objOU.Filter = Array("user")

' Enumerate users objects.
For Each objUser In objOU
' Skip computer objects.
If (LCase(objUser.Class) = "user")
intUAC = objUser.Get("userAccountControl")
' Check if the bit is already set.
If (intUAC AND ADS_UF_SMARTCARD_REQUIRED) = 0 Then
' The bit is not set. Set the bit.
intUAC = intUAC OR ADS_UF_SMARTCARD_REQUIRED
objUser.Put "userAccountControl", intUAC
' Save change.
objUser.SetInfo
End If
End If
Next
==========
The AND operator is used to test the flag attribute (userAccountControl)
with the bit mask ADS_UF_SMARTCARD_REQUIRED. Any non-zero result means the
bit is set, while a zero result means the bit is not set. The OR operator is
used to set the bit. The XOR operator toggles the bit. In this case, you
could use either OR or XOR, since we first test to see that it is not set.
The XOR operator must be used to un-set (clear) a bit.

--
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 21h50.


É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,08704 seconds with 10 queries