Afficher un message
Vieux 07/09/2007, 23h37   #7
Kshaeta
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Trying to compare usernmae to a group membership

I found a less simpler way.
thanks though!
bill

--
Bill Tkach
MSP, CCNA, A+
visual{period}eyes{at}telus{period}netJ Ford wrote:



> Its a hack...
>
> <script>
> ' wscript.arguments(0) = <Your Domain>
> ' wscript.arguments(1) = <Your Group>
>
> Set oGroup = GetObject("WinNT://" & wscript.arguments(0) & "/" &
> wscript.arguments(1), group)
> Set oShell = CreateObject("WScript.Shell")
> Set oFSO = CreateObject("Scripting.FileSystemObject")
>
> sUserName = UCase(oShell.ExpandEnvironmentStrings("%USERNAME%" ))
>
> sMembers = ""
>
> For Each oMember in oGroup.Members
> sMembers = sMembers & ";" & UCase(oMember.Name)
> Next
>
> If InStr(sMembers, sUserName) <> 0 Then
> Set FileName = oFSO.GetFile("file.txt")
> FileName.Delete
> Else
> Set FileName = oFSO.GetFile("file2.txt")
> FileName.Delete
> End If
> </script>
>
> "Kshaeta" wrote:
>
>> The problem isn't finding out if the person is in the group, the problem
>> is using that script in say, an if/then statement.
>> Sort of like
>> IF (dsget group "CN=Dudes,OU=OurOU,OU=ABC Network,DC=abcdef,DC=ca"
>> -expand -members | dsget user -samid -c | find "%USERNAME%" ==
>> %USERNAME%) DEL file.txt ELSE DEL file2.txt
>>
>> However, I can't do the above; It won't let me compare the "dsget..." to
>> the %USERNAME%.
>>
>> PS - I don't know if the del things works, thats not the problem. It's
>> just to figure out how to get a true/false comparison.
>>
>> bill
>>
>>
>> Richard Mueller [MVP] wrote:
>>> Bill Tkach wrote:
>>>
>>>> I have a batch file script, that needs to see if a person belongs to a
>>>> certain group. So I'm trying to compare the %USERNAME% (logged on user) to
>>>> the members of the group, to see if I can get either a "doesn't match" or a
>>>> "does match".
>>>>
>>>> Here's my query
>>>>
>>>> dsget group "CN=Dudes,OU=OurOU,OU=ABC
>>>> Network,DC=abcdef,DC=ca" -expand -members | dsget user -samid -c | find
>>>> "%USERNAME%"
>>>>
>>>> So, if you pass it the %username%, and there's a match, it returns the
>>>> username.
>>>> So, this gives me a name, but I can't match it the %USERNAME%... I can
>>>> only get it to return the value. I can't get past this step.
>>>>
>>>> Is there another way to compare this, or, am I almost there?
>>>>
>>>> --
>>>> Bill Tkach
>>>> MSP, CCNA, A+
>>>> visual{period}eyes{at}telus{period}net
>>> It seems to work. If a name is echoed, the current user is a member. If
>>> nothing is echoed, the current user is not a member of the group. What do
>>> you want to accomplish?
>>>

>>
>> --
>> Bill Tkach
>> MSP, CCNA, A+
>> visual{period}eyes{at}telus{period}net
>>

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