Results 1 to 5 of 5

Thread: Get dominoGroup from username by using asp.net

  1. #1
    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.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    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

    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.

  3. #3
    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));
    }
    }

  4. #4
    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

  5. #5
    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?

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,272,828.46740 seconds with 17 queries