Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

AD

Last post 05-02-2008 8:14 PM by kruelintent. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 05-02-2008 5:20 AM

    hi,

    I need to implement AD(active directory ) to my project .can anyone guide how can i implement AD ??

    regards,

    elango.v

    • Post Points: 10
  • 05-02-2008 8:14 PM In reply to

    • kruelintent
    • Top 200 Contributor
    • Joined on 01-02-2003
    • United Kingdom
    • Addicted Member
    • Points 700

    Re: AD

    No specifics in the question so I will be general with my answer.

    In IIS you need to make sure you are using windows authentication on the website.

    In the code behind you can get the users login credentials using

    strUserName = Right(Context.User.Identity.Name.ToString, Len(Context.User.Identity.Name.ToString) - InStr(Context.User.Identity.Name.ToString, "\"))

    If you are using SQL Server you can even interogate the AD using a linked server and stored proc.....

    If you link to ADSI you should be able to use something like this to list out the domain users to a list

    select givenName, sn, objectguid from openquery
    (
    ADSI,'SELECT givenName, sn, objectguid, scriptpath
    FROM ''LDAP://domain.com''
    WHERE objectCategory = ''Person'' AND objectClass = ''user'''
    )
    WHERE givenName IS NOT NULL and sn IS NOT NULL
    order by sn

    In full. If you wanted to check if some user was part of a user group then you could use code like this....(Where Check AD Member is a stored proc in the DB against ADSI)

    strUserName = Right(Context.User.Identity.Name.ToString, Len(Context.User.Identity.Name.ToString) - InStr(Context.User.Identity.Name.ToString, "\"))

    Dim param(1) As SqlClient.SqlParameter

    param(0) = New SqlClient.SqlParameter("@SAMAccountName", strUserName)

    param(1) = New SqlClient.SqlParameter("@SecurityGroup", "CN=SecurityGroup,CN=Users,DC=DOMAIN,DC=com")

    If SqlHelper.ExecuteReader(ConfigurationSettings.AppSettings("CONNECTIONSTRING"), CommandType.StoredProcedure, "CheckADMember ", param).HasRows Then

    blnResult = True

    Else

    blnResult = False

    End If

    ==========================

    There you go. General, but I hope it helps in some way. Google "ADSI linked server" for some more help on using the active directory from SQL Server

    Cheers

    • Post Points: 5
Page 1 of 1 (2 items)