views:

351

answers:

2

Hi

Im writing a program for my school in which users have to enter a code given to them by a teacher to access the internet.

My Question is how can i from delphi check if the current user is part of the teacher security group in active directory or not before it runs my code generating program.

Thanks Erik

+3  A: 

Using winapi functions.

But have a look at Jedi JWSCL, that is an underdivision of Jedi APIlib that are building a security related library for Delphi.

http://blog.delphi-jedi.net/category/downloads/jwscl-downloads/

Marco van de Voort
+1 For suggesting Jwscl
Remko
Sorry, User and Groups Management is currently not supported by JWSCL. However, there are plans and a unit skeleton for this feature. Only missing thing is time or volunteer(s).
ChristianWimmer
Christian: is there a good overview soemwhere what IS there?
Marco van de Voort
Just finished this article for you: http://blog.delphi-jedi.net/2010/02/22/jwscl-features-overview/
ChristianWimmer
I have started with the implementation of JwsclActiveDirectory...
Remko
A: 

See the answers in this post

Gerard
Ive had a look at this but i am struggling on working out how to use the unit there. If i can papulate a stringgrid or listbox with a users groups i can easily work it out from there. Or can i only search for a predefined groupname?
Erik
Using the code example I posed in that thread, just call TADSI.GetUser and inspect the returned Groups value. Or call TADSI.Authenticate(Domain, UserName, Group: string) and pass the name of the Group for "teacher security".
Gerard
Thanks for your help. ive manageds to whittle through some of the errors i was getting and im now stuck with undeclaired identifer group also how do i pass it the group name? do i replace string? Thanks
Erik
Firstly, TASDI.Authenticate returns a boolean so assigning that to a Caption property wont work. Secondly, you need to CREATE the TADSI object, assign it to a variable and then call the methods, e.g.var ActiveDir: TADSI; Authenticated: boolean;begin ActiveDir:=TADSI.Create(Self); Authenticated:=ActiveDir.Authenticate('DomainName','UserName','GroupName); ActiveDir.Free;
Gerard
Hi gerard. thanks for your patiance. And thank you verry much. the program is now working perfectally. i had to take out activedir.free as it was spitting out read errors, but now it works perfectally fine. Once again thanks :-)
Erik
How about tagging this post as Answered?
Gerard