Checking if a user is a member of group from a service

  • Thread starter Thread starter Jm
  • Start date Start date
J

Jm

Hi all

Im currently converting a windows service from vb6 to vb.net and im unsure
about how to use the new directory services interface. Under vb6 i would add
a reference to the directory services and basically put

dim usr as iadsuser
dim grp as iadsgroup

Which obviouslly you cant do. So i tried to use a basic vbscript equivalent
but i dont get anything returned (error or otherwrise). This is the code im
using:

dim grp as object
dim staff as string

Try
Grp = GetObject("WinNT://Hms.Intranet/Staff,group")
Catch ex As Exception
MsgBox("GetObj" & Err.Number & Err.Description)
End Try
IsStaff = Grp.IsMember("WinNT://Hms.Intranet/Staff)

This code seems to work from a windows app but not inside a windows service.
Im unsure why this is so, but im sure there is a good reason. So im guessing
there is any easy equivalent under vb.net of the old iasduser and iadsgroup.
Any help is greatly appreciated

Thanks
 
Hi,

Take a look at the windowsprincipal isinrole method.

http://msdn.microsoft.com/library/d...incipalwindowsprincipalclassisinroletopic.asp

Ken
--------------------
Hi all

Im currently converting a windows service from vb6 to vb.net and im unsure
about how to use the new directory services interface. Under vb6 i would add
a reference to the directory services and basically put

dim usr as iadsuser
dim grp as iadsgroup

Which obviouslly you cant do. So i tried to use a basic vbscript equivalent
but i dont get anything returned (error or otherwrise). This is the code im
using:

dim grp as object
dim staff as string

Try
Grp = GetObject("WinNT://Hms.Intranet/Staff,group")
Catch ex As Exception
MsgBox("GetObj" & Err.Number & Err.Description)
End Try
IsStaff = Grp.IsMember("WinNT://Hms.Intranet/Staff)

This code seems to work from a windows app but not inside a windows service.
Im unsure why this is so, but im sure there is a good reason. So im guessing
there is any easy equivalent under vb.net of the old iasduser and iadsgroup.
Any help is greatly appreciated

Thanks
 
Back
Top