Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 24-07-2009
Member
 
Join Date: Jul 2009
Posts: 3
question Get dominoGroup from username by using asp.net

Hi All,

Please help. How to retrieve groups from username by using asp.net ?
My ldap server is domino ldap server. Thank you very much.
Reply With Quote
  #2  
Old 24-07-2009
Member
 
Join Date: Jan 2008
Posts: 1,515
Re: Get dominoGroup from username by using asp.net

For that you need to put the following code, whenever you log from username by using asp.net. If you need to when the page first loads, the you can do this in the Page_Load or Page_Init Events

Quote:
Sub Page_Load( Object as sender, EventArgs as e )

Dim username as String = Page.User.Identity.Name

'do something with username

End Sub
Hope so it may help you out.
Reply With Quote
  #3  
Old 24-07-2009
Member
 
Join Date: Jul 2009
Posts: 3
Re: Get dominoGroup from username by using asp.net

Hi Modifier,

Thanks for your help first.
I mean that finding domino groups of logged in user.
e.g.
Searched by kelvin

Group List
-----------
IT Department

I found simlar source code, but it doesn't work.
StringCollection groups = new StringCollection();


DirectorySearcher srch = new DirectorySearcher(RootDirectoryEntry,"(sAMAccountName=" + strUser + ")");

// set properties to retrieve
srch.PropertiesToLoad.Add("memberOf");
srch.PropertiesToLoad.Add("sAMAccountName");

// find one entry since there should be no duplicates of sam account name
// in the active directory
SearchResult res = srch.FindOne();

// clear the groups collection for safe measure
groups.Clear();

// get the number of groups that the user is a member of
int propertyCount = res.Properties["memberOf"].Count;

// create some variables for the looping through groups
String dn;
int equalsIndex, commaIndex;

// loop through groups
for( int propertyCounter = 0; propertyCounter < propertyCount; propertyCounter++)
{
dn = (String)res.Properties["memberOf"][propertyCounter];

// the following is used to remove the cn= etc...
equalsIndex = dn.IndexOf("=", 1);
commaIndex = dn.IndexOf(",", 1);
if (-1 == equalsIndex)
{
}
else
{
// add string to group collection
groups.Add(dn.Substring((equalsIndex + 1),(commaIndex - equalsIndex) - 1));
}
}
Reply With Quote
  #4  
Old 24-07-2009
Member
 
Join Date: Jul 2009
Posts: 3
Re: Finding domino groups of logged in user by using asp.net

Hi All,


Here is attached my source code, I try to pass administrator or user account, but the error message shown "Accessed Denied".

ldappath = "LDAP://192.168.1.10"

Dim MyDirectory As DirectoryEntry

MyDirectory = New DirectoryEntry(ldappath, txtUsername, txtPassword, AuthenticationTypes.None)

Dim groups As StringCollection = New StringCollection()

Dim srch As DirectorySearcher = New DirectorySearcher(MyDirectory, "(&(givenName=" + txtUsername + "))")

srch.PropertiesToLoad.Add("memberOf")
srch.PropertiesToLoad.Add("givenName")
srch.SearchScope = SearchScope.Subtree

Dim res As SearchResult = srch.FindOne()

groups.Clear()

Dim propertyCount As Integer = res.Properties("memberOf").Count

Dim dn As String

Dim equalsIndex, commaIndex As Integer

For propertyCounter As Integer = 0 To propertyCounter < propertyCount
dn = res.Properties("memberOf")(propertyCounter).ToString
equalsIndex = dn.IndexOf("=", 1)
commaIndex = dn.IndexOf(",", 1)
If (-1 = equalsIndex) Then
Else
groups.Add(dn.Substring((equalsIndex + 1), (commaIndex - equalsIndex) - 1))
End If
Next
Reply With Quote
  #5  
Old 24-07-2009
Member
 
Join Date: Apr 2008
Posts: 43
Re: Get dominoGroup from username by using asp.net

Hi,

I have similar problem & I used WindowsTokenRoleProvider & I could find out my username & got all the Groups I belong on my system. CAn I do the same but against active directory? Do I need to use "AuthorizationStoreRoleProvider"? & install azman?
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags:



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Get dominoGroup from username by using asp.net"
Thread Thread Starter Forum Replies Last Post
How to Get Current Username in VB.NET Samir_1 Software Development 4 13-03-2014 11:43 AM
Every process is without username Erakna Operating Systems 6 05-08-2011 03:10 PM
Need help for getting the DSL username and password Road-Runner Networking & Security 4 03-12-2010 05:18 PM
How to change facebook username Harvey Technology & Internet 3 11-09-2009 06:46 PM
SID not resolving to Username Nadeem Active Directory 5 05-01-2009 06:26 PM


All times are GMT +5.5. The time now is 01:31 PM.