kimosavi
Active member
Hi,
I started developing an application in WPF w/VB and want to set the security to work with Domain Groups.
In there Database there is a table that stores the Domain and Group name.
When an user opens the application the application will search for the list of groups and validate that the user belogs to this list. If so, will open the app otherwise will exit. There will also be another table with individual usernames in case the Admin will like to just add one individual and not just a full group.
My problem is that, this is the first time attempting to do something like this and I have no knowledge of what imports, libraries or services should I use.
Currently I did the following:
Method 1 worked well with my local groups but took FOR EVER! to go down a list of 5 groups... It was wasting a lot of time in
vGroup = DirectoryServices.AccountManagement.GroupPrincipal.FindByIdentity(IsPublic.CurrentUser.Identity.Context, Row.Item("Domain") + "\" + Row.Item("Name"))
Method 2 didn't work so well... its was looking for ROLES not GROUPS right? not sure the different, I think ROLES are more for Web Security right?
My plan was to get a list of all the groups from Active directory that the user is a member of and then validate that with the groups setup in the db. if they match, user can log in. Read a lot of stuff but got me more confused.
How do I get such list from Active Directory? Will I be able to test this in my Win 7 PC (not in the network)?
Domain: Marketing.Global.Corp
User : MARKETING\myusername
Thanks!
I started developing an application in WPF w/VB and want to set the security to work with Domain Groups.
In there Database there is a table that stores the Domain and Group name.
When an user opens the application the application will search for the list of groups and validate that the user belogs to this list. If so, will open the app otherwise will exit. There will also be another table with individual usernames in case the Admin will like to just add one individual and not just a full group.
My problem is that, this is the first time attempting to do something like this and I have no knowledge of what imports, libraries or services should I use.
Currently I did the following:
VB.NET:
' Method1
Dim rs As New App.Services.Data.RecordSet("SELECT * FROM TBL_Security_Groups", "TBL_Security_Groups")
For Each Row As System.Data.DataRow In rs.Results.Rows
Dim vGroup As DirectoryServices.AccountManagement.GroupPrincipal
vGroup = DirectoryServices.AccountManagement.GroupPrincipal.FindByIdentity(IsPublic.CurrentUser.Identity.Context, Row.Item("Domain") + "\" + Row.Item("Name"))
If Not vGroup Is Nothing Then
If DirectoryServices.AccountManagement.UserPrincipal.Current.IsMemberOf(vGroup) Then
vResults = True
Exit For
End If
End If
Next
' Method2
Dim rs As New App.Services.Data.RecordSet("SELECT * FROM TBL_Security_Groups", "TBL_Security_Groups")
For Each Row As System.Data.DataRow In rs.Results.Rows
If My.User.IsInRole(Row.Item("Domain") + "\" + Row.Item("Name")) Then
vResults = True
Exit For
End If
Next
Method 1 worked well with my local groups but took FOR EVER! to go down a list of 5 groups... It was wasting a lot of time in
vGroup = DirectoryServices.AccountManagement.GroupPrincipal.FindByIdentity(IsPublic.CurrentUser.Identity.Context, Row.Item("Domain") + "\" + Row.Item("Name"))
Method 2 didn't work so well... its was looking for ROLES not GROUPS right? not sure the different, I think ROLES are more for Web Security right?
My plan was to get a list of all the groups from Active directory that the user is a member of and then validate that with the groups setup in the db. if they match, user can log in. Read a lot of stuff but got me more confused.
How do I get such list from Active Directory? Will I be able to test this in my Win 7 PC (not in the network)?
Domain: Marketing.Global.Corp
User : MARKETING\myusername
Thanks!