bsharath
asked on
Check that check groups for members and places the group name that its available. One group data is not pulled.
Hi,
Check that check groups for members and places the group name that its available. One group data is not pulled.
Full time works but not the other group. even if the user is a member i get "NO"
If the user is a member of both groups for few i ger and for few NO
This script check the colum names with the Active directory group.
Regards
sharath
Check that check groups for members and places the group name that its available. One group data is not pulled.
Full time works but not the other group. even if the user is a member i get "NO"
If the user is a member of both groups for few i ger and for few NO
This script check the colum names with the Active directory group.
Regards
sharath
Sub Check_If_Member_Of_Internet_Groups()
strGroupToCheck1 = "Full Time"
strGroupToCheck2 = "Full Time Internet"
Set objNetwork = CreateObject("WScript.Network")
For intRow = 2 To Cells(65536, "L").End(xlUp).Row
strNTLogin = Trim(Cells(intRow, "L").Value)
If strNTLogin <> "" Then
If Trim(Cells(intRow, "BJ").Value) = "" Then
On Error Resume Next
Set objWinntUser = GetObject("WinNT://" & objNetwork.UserDomain & "/" & strNTLogin & ",user")
If Err.Number = 0 Then
On Error GoTo 0
If (IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck1) = True) And (IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck2) = True) Then
Cells(intRow, "BJ").Value = strGroupToCheck1 & " and " & strGroupToCheck2
ElseIf (IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck1) = True) Or (IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck1) = True) Then
If IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck1) = True Then
Cells(intRow, "BJ").Value = strGroupToCheck1
ElseIf IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck2) = True Then
Cells(intRow, "BJ").Value = strGroupToCheck2
End If
ElseIf (IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck1) = False) And (IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck1) = False) Then
Cells(intRow, "BJ").Value = "No"
End If
Else
Err.Clear
On Error GoTo 0
End If
Set objWinntUser = Nothing
End If
End If
Next
End Sub
Function IsMemberOfGroup(strUserDomain, objuser, strGroup) 'the user is a member of a specified group
IsMemberOfGroup = False
Dim objGroup
On Error Resume Next
Set objGroup = GetObject("WinNT://" & strUserDomain & "/" & strGroup & ",group")
If Err.Number Then
IsMemberOfGroup = "Error"
Else
IsMemberOfGroup = objGroup.IsMember(objuser.adsPath)
'MsgBox objUser.ADsPath
End If
End Function
Can you clearly state your question please?
ASKER
This script checks these 2 groups if the users are a member of 1 or both these groups
strGroupToCheck1 = "Full Time"
strGroupToCheck2 = "Full Time Internet"
It does not get the info from the group2
strGroupToCheck1 = "Full Time"
strGroupToCheck2 = "Full Time Internet"
It does not get the info from the group2
ASKER
This script checks these 2 groups if the users are a member of 1 or both these groups
strGroupToCheck1 = "Full Time"
strGroupToCheck2 = "Full Time Internet"
It does not get the info from the group2
strGroupToCheck1 = "Full Time"
strGroupToCheck2 = "Full Time Internet"
It does not get the info from the group2
Chech your spelling in every instance of "Full Time Internet", and make sure it is spelled *exactly* the way it was originally assigned.
Also, obvoiusly, make sure that what you are searching for is actually in that group.
;-)
JeffCoachman
Also, obvoiusly, make sure that what you are searching for is actually in that group.
;-)
JeffCoachman
sharath,
can you post a sample sheet where this macro fails to work?
Thanks,
Ardhendu
can you post a sample sheet where this macro fails to work?
Thanks,
Ardhendu
ASKER
Jeff the names are perfect...
Pari.
The file just has names in colum "L" which needs to query active directory groups and put in results as if the user is a member of the group or not.
Pari.
The file just has names in colum "L" which needs to query active directory groups and put in results as if the user is a member of the group or not.
ASKER
Jeff the names are perfect...
Pari.
The file just has names in colum "L" which needs to query active directory groups and put in results as if the user is a member of the group or not.
Pari.
The file just has names in colum "L" which needs to query active directory groups and put in results as if the user is a member of the group or not.
Sharath,
Activedirectory is not one of my strong points. So I dont think I would be able to help you on this.
- Ardhendu
Activedirectory is not one of my strong points. So I dont think I would be able to help you on this.
- Ardhendu
ASKER
Ok Pari thanks....
ASKER
Ok Pari thanks....
Hi Sharath,
This code works fine for me as it is.
Remember that the code will only re-check the groups if column BJ is empty for the row your querying.
Also, make sure you are viewing the entire data in that cell. For example, when I run mine with GroupA and GroupB, the BJ cell then says
GroupA and GroupB
Maybe your column isn't wide enough to view the data?
What happens if you change
strGroupToCheck1 = "Full Time"
strGroupToCheck2 = "Full Time Internet"
to
strGroupToCheck1 = "Full Time Internet"
strGroupToCheck2 = "Full Time"
Do the results then swap around?
Regards,
Rob.
This code works fine for me as it is.
Remember that the code will only re-check the groups if column BJ is empty for the row your querying.
Also, make sure you are viewing the entire data in that cell. For example, when I run mine with GroupA and GroupB, the BJ cell then says
GroupA and GroupB
Maybe your column isn't wide enough to view the data?
What happens if you change
strGroupToCheck1 = "Full Time"
strGroupToCheck2 = "Full Time Internet"
to
strGroupToCheck1 = "Full Time Internet"
strGroupToCheck2 = "Full Time"
Do the results then swap around?
Regards,
Rob.
ASKER
Hi Rob,
Yes the colum i removed all the data and ran and i get just 1 group and for the other group i get "NO"
Not even 1 user it retrieves if its in the other group
Yes the colum i removed all the data and ran and i get just 1 group and for the other group i get "NO"
Not even 1 user it retrieves if its in the other group
ASKER
Hi Rob,
Yes the colum i removed all the data and ran and i get just 1 group and for the other group i get "NO"
Not even 1 user it retrieves if its in the other group
Yes the colum i removed all the data and ran and i get just 1 group and for the other group i get "NO"
Not even 1 user it retrieves if its in the other group
If you swap the group names around, do you get different results?
ASKER
I did swap the names now. And now they work the other way. The names which got the groups show as "NO" and the other group works now
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks it works...
If a user is member of both groups. Will it show....
If a user is member of both groups. Will it show....
ASKER
Thanks it works...
If a user is member of both groups. Will it show....
If a user is member of both groups. Will it show....
Yes, it should show
Group1Name and Group2Name
in the BJ column.
Rob.
Group1Name and Group2Name
in the BJ column.
Rob.
ASKER
Thank u Rob worked perfect
:-))
:-))