OK. Some functions that I use....
Imports System.Security.Principal
'Returns current user
Public Function CurrentUser()
Dim pos As Integer, fullname As String
fullname = System.Security.Principal.WindowsIdentity.GetCurre nt().Name
'Just to get at the username after the 'domainname\' Should really use
Substring instead of Mid
pos = InStr(fullname, "\", CompareMethod.Text)
CurrentUser =
Mid(System.Security.Principal.WindowsIdentity.GetC urrent().Name, pos + 1)
End Function
'To test whether user is a member of a group
Private Function InGroup(ByVal grp As String) As Boolean
Dim id As WindowsIdentity
id = WindowsIdentity.GetCurrent()
Dim p As New WindowsPrincipal(id)
InGroup = p.IsInRole("YourDomainName\" + grp)
End Function
....and a sample Sub Main()....
Sub Main()
dim msg as string
If InGroup("AppUsers") Then
Application.Run(New YourMainForm)
Else
msg = "You are not a registered user. Please go away."
MessageBox.Show(msg, "Invalid user", MessageBoxButtons.OK)
End If
End Sub
"Rod Barrand" <rb******@johnstonnsmclamb.com> wrote in message
news:u8**************@tk2msftngp13.phx.gbl...
Rob, thats exactly what im looking for too, any examples would be grateful
"Rob Oldfield" <rob@oldfield100_wow_freeserve_yikes_co_incredible !_uk>
wrote in message news:O%****************@TK2MSFTNGP12.phx.gbl... No answers here I'm afraid Brad, but just to say that I don't really
understand exactly what it is you're trying to achieve. I have a
windows forms app that checks who the logged in user is and only allows access
if they are a member of a particular AD group (or groups). Is that what you're after? If not, it'll probably be worth a repost with an example of what
functionality you want.
"Brad" <an*******@discussions.microsoft.com> wrote in message
news:73**********************************@microsof t.com... Hello All,
I am trying to write a vb.net windows application, this application
will have a logon that I want to "tie" to the Active Directory that is
running on the network. Where do I look to get started integrating with LDAP. Is it
easy to program the Logon feature? Is there some sample code out there?
Thanks
Brad