locked
Active Directory problem updating RRS feed

  • Question

  • User-625738215 posted

    Split off from http://forums.asp.net/t/1323744.aspx/1?Active+Directory+problem+updating#

    Dear all please tell me i want to update manager feilds i can find it by manger property or superwisername ,,,,i cant set or get manger property pelase anyone help me thanks

    Thursday, December 1, 2011 9:40 AM

Answers

  • User1508394307 posted

    Manager property contains a "distinguished name" (DN) - i.e. an LDAP path - for the manager's DirectoryEntry.

    DirectoryEntry e = new DirectoryEntry("LDAP://cn=John Doe,cn=Users,dc=YourCorp,dc=com");
    
    // If user already has reference to a manager, delete it.
    if (e.Properties.Contains("manager"))
        e.Properties["manager"].Clear();
    
    e.Properties["manager"].Insert(0, "cn=Boss,cn=VIP Users,dc=YourCorp,dc=com");
    
    e.CommitChanges();

    Hope this helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 2, 2011 3:52 PM

All replies

  • User1508394307 posted

    Manager property contains a "distinguished name" (DN) - i.e. an LDAP path - for the manager's DirectoryEntry.

    DirectoryEntry e = new DirectoryEntry("LDAP://cn=John Doe,cn=Users,dc=YourCorp,dc=com");
    
    // If user already has reference to a manager, delete it.
    if (e.Properties.Contains("manager"))
        e.Properties["manager"].Clear();
    
    e.Properties["manager"].Insert(0, "cn=Boss,cn=VIP Users,dc=YourCorp,dc=com");
    
    e.CommitChanges();

    Hope this helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 2, 2011 3:52 PM
  • User636753033 posted

    If no manager has been applied to the user object, there will be no manager field to pull information from. Before trying to use any information from an account you will want to check to see if that field exists. You can use and if/else block or a try/catch block.

    If e.properties.contains("manager") Then
    
    'assign value to output field
    
    Else
    
    'assign text to output alerting propery is not populated
    
    End If
    Try
    
    mangertxt.text = e.properties.contains("manager") 
    
    Catch
    
    managertxt.text = "Manager field is not populated"
    
    End Try

    If you want to set the manager name, you will want to make a function that looks up the distinguished name of the person you want to assign as the manager, using their samaccountname. The distinquishedname can be long and will not update correctly if its not formatted properly if you try to manually enter it.

    Public Function Get ManagerDistinguishedName("bob.smith") as string
    
    'enter code to search AD for "bob.smith" and return his distinguishedname
    
    End Fuction

    If you need specific samples of this i can post it later.

     

    Sunday, December 4, 2011 8:54 AM