Update user details in Active directory- telephone info RRS feed

  • Question

  • User-1594993325 posted

    I am using web services with windows authentication integrated for update users detail inactive directory

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>public static DirectoryEntry GetDirectoryEntry(string path)<o:p></o:p>{<o:p></o:p><o:p> </o:p>        DirectoryEntry de = new DirectoryEntry(path);<o:p></o:p>

      de.Username = ConfigurationManager.AppSettings["Aduser"].ToString(); 

      de.Password = ConfigurationManager.AppSettings["AdPwd"].ToString(); <o:p></o:p>        de.AuthenticationType = AuthenticationTypes.Secure;<o:p> </o:p>

            return de;

    }<o:p></o:p><o:p> </o:p>


    public bool updateUserInfo(string uname, string strtelephone)<o:p></o:p>


      DirectoryEntry de = GetDirectoryEntry("LDAP://Ldapservername");<o:p></o:p>        DirectorySearcher deSearch = new DirectorySearcher();<o:p></o:p>        deSearch.Filter = "CN=" + UserName;<o:p></o:p>        deSearch.SearchRoot = de;<o:p></o:p>        deSearch.SearchScope = SearchScope.Subtree;<o:p></o:p>        try<o:p></o:p>        {<o:p></o:p>            if (results == null)<o:p></o:p>            {<o:p></o:p>                return false;;    <o:p></o:p>            }<o:p></o:p>            else<o:p></o:p>            { <o:p></o:p>                DirectoryEntry updateEntry = results.GetDirectoryEntry();<o:p></o:p>   // updateEntry.Username = “jil”;<o:p></o:p>               // updateEntry.Password = "Pass3";<o:p></o:p>                updateEntry.Properties["telephoneNumber"].Value = strtelephone;<o:p></o:p>                updateEntry.CommitChanges();<o:p></o:p>                updateEntry.Close();<o:p></o:p>                return true;    <o:p></o:p>            }<o:p></o:p>        }<o:p></o:p>        catch(Exception ex)<o:p></o:p>        {<o:p></o:p>            return false; <o:p></o:p>        }<o:p></o:p><o:p> </o:p>In the above code I try to modify the telephone number of my login.<o:p></o:p>

    It gives General access denied error\r\n" error.


    if I uncomment this 2 lines  

    //updateEntry.Username = “jil”;<o:p></o:p>

    //updateEntry.Password = "Pass3";

    <o:p></o:p> It works fine.I am writing a genral application based on windows nt login, each user can change the personal informaion of theirs.<o:p></o:p><o:p> </o:p>My problem is, I am giving ldap user name and password.why should I once again give the windows password to change my details.<o:p></o:p><o:p> </o:p>Is it anything wrong in my code?<o:p></o:p><o:p> </o:p>Help Needeed<o:p></o:p>Advance thanks<o:p></o:p>JIL<o:p></o:p>


    Wednesday, June 20, 2007 2:33 PM

All replies

  • User-1495957243 posted

    You question is very hard to read but I will try help.

    Firstly, make sure your webservice is set to anonymous security... if it's not then you will be prompted for credentials.

    Secondly, make sure you connect to AD with an account that has read/write access to AD. Usually the application that is doing a writing is given a specific account that is restricted to do only what you need.  That account is what you should be connecting to AD with.

    You should not have to send any of the user specific authentication information because you app account should have access be able to do everything it needs.

    Wednesday, June 20, 2007 6:25 PM