Sign in to follow this  
Followers 0
commenti

Newbie Question: Groups

5 posts in this topic

Hi!

I am new to AutoIT. I tried out some scripting and I like this language. I now think about migrating my current scripts (KIX-Script) to AuotIT. So far everything I tried worked well. But now I have a problem I could not solve seraching the help or the forum. Sorry if I´ve overseen this but how can I find out with AutoIT if a user is in group a b or c? or a +b or both or somehting like this.

I want to have somehting like this.

User is logged in to domain EXAMPLE.

IfInGroup "booking"

netuse U: //Example/exampleDir1

EndIF

IfINGroup "booking"

netuse Y: //Example/exampleDir2

EndIF

How can I do something like this in AutoIT?

I would be happy for a little help. Perhaps I have only overseen the commands to deterimine if a user belongs to a certain group.

Commenti

Share this post


Link to post
Share on other sites



Welcome to the world of Microsoft's lack of functionality.

There are a couple of utilities out there that query a domain for group memberships. Here is a link to some articles: http://www.jsiinc.com/SUBL/tip5700/rh5772.htm

If you want to do it without the utils, you must first query the domain using:

net user /DOMAIN user

Pipe the result into a text file

net user /DOMAIN user > c:\temp\result.txt

Then find the string you are looking for using this script

To find the string "GroupA" in the file result.txt

//Get the user details and pipe to a text file
RunWait(@ComSpec & " /c " & 'net user /DOMAIN user > c:\temp\result.txt', "", @SW_HIDE)

//Query the text file
$a = RunWait('find /n "GroupA" C:\temp\result.txt',"",@SW_HIDE)

//Do some if stuff
If $a = 1 Then
 MsgBox(4096,"",'user is NOT part of "GroupA"')
Else
 MsgBox(4096,"",'user is part of "GroupA"')
EndIf

It relies on the good ol DOS, but it should work.

Cheers

Nobby :D


CheersNobby

Share this post


Link to post
Share on other sites

Microsoft supplies an own utility for this within the Windows Ressource Kits (called ifmember.exe)

Share this post


Link to post
Share on other sites

Hi!

Thank you, both of you.

I would prefer a function to determine groups in autoit, but your suggestion do at least work. From this two I think, I´ll use nobbys idea and make an autoit function out of it. Both suggestions have the problem, that I have to rely on extra soft (o.k. net user should be avaible at least on all W2K and WXP Maschines). That was better in kix-script, there I had a function like this:

IF InGroup( "Hello")

Do something

EndIF.

But with nobbys idea its at least possible to write a workaround for that.

I miss some more functions. I think I´ll try to code workarounds in autoit. If they are ready I´ll post them. Thanx again for your help.

commenti

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0