Windows authenication and owner of the record RRS feed

  • Question

  • User387771865 posted

    Hi, In my intranet website I'm using Windows authenication. My application uses SQL server to store informations passed by the users. How to provide infromation who is an owner of particular information? For example my data table consists of following fields: InformationID, InformatinSubject, InformationDescription, InformationOwner. What kind of information should I use in InformationOwner field of the record? Is it enough to use string which I got using User.Identity.Name or maybe it will be better to use SID from AD for particular user? How to get e-mail of this user from AD?

    I'm looking for exmaples of application which uses Active Directory as a source of information about user, his full name, his e-mail etc.? Thanks. Pawel.

    Saturday, December 13, 2008 5:41 AM

All replies

  • User-523094406 posted


     I would look at storing the most unique value, is AD this would be the SID. You could also use the login or legacy DN value.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>As for getting the email address from AD, you need to use the DirectorySearcher methods in .net.<o:p></o:p>Here is the MSDN example http://msdn.microsoft.com/en-us/library/w4y82e8a(VS.71).aspx:<o:p></o:p>System.DirectoryServices.DirectoryEntry entry = <o:p></o:p>  

        new System.DirectoryServices.DirectoryEntry(LDAP://Path);

    <o:p></o:p>System.DirectoryServices.DirectorySearcher mySearcher = new <o:p></o:p>   System.DirectoryServices.DirectorySearcher(entry);<o:p></o:p>mySearcher.Filter = ("(anr= John)");<o:p></o:p>foreach(System.DirectoryServices.SearchResult result in mySearcher.FindAll()) <o:p></o:p>{<o:p></o:p>  

    Console.WriteLine( result.GetDirectoryEntry().Path );

    <o:p></o:p>}<o:p></o:p>To find the correct user or record in AD, you need to set the .Filter value. Once you find the user you want, the value for MAIL will return their current default SMTP email address. You will just need to search the results<o:p></o:p>



    Sunday, December 14, 2008 7:35 AM