views:

21

answers:

2

i am using role provider and have it managing users on my intranet via their windows logins. how can i pull their email address and maybe some other user content from asp.net using their user info?

do i need to hook into active directory? a sample fir this would be great if this is the way to go

thanks all

+1  A: 

The membership provider is responsible for this, there is an Email property on the MembershipUser class. (Remember that it should work the same irrespective of the provider, SQL or AD)

Check this MSDN article for detailed information

Mikeware
i am using roles provider, not membership provider.
kacalapy
Roles provider will not get you that information, it is for establishing authorization to users, not to authenticate users or getting their info. You may have to use the membership provider for Windows Clients, or use Directory Services to obtain user information.
Mikeware
A: 

i folks, here is how you can pull any data points from Active Directory. in my code i get the user's email

SELECT mail FROM 'LDAP://DC=Domain,DC=win,DC=ml,dc=COM' WHERE samaccountname = 'userName'

              System.Data.OleDb.OleDbConnection con;
              System.Data.OleDb.OleDbDataAdapter da;
              System.Data.OleDb.OleDbCommand cmd;
              System.Data.DataTable dt = new System.Data.DataTable();

              con = new System.Data.OleDb.OleDbConnection("Provider=ADsDSOObject;dsn=Active Directory Provider");
              con.Open();

              //                Create a command object on this connection

              cmd = new System.Data.OleDb.OleDbCommand(this.tbQuery.Text, con);
              da = new System.Data.OleDb.OleDbDataAdapter();
              da.SelectCommand = cmd;

              try
              {
                    da.Fill(dt);
                    this.dgResults.DataSource = dt;
              }
              catch (System.Data.OleDb.OleDbException exc)
              {
                    MessageBox.Show(exc.Message);
              }
              con.Close();
kacalapy