Solved

C# setting extensionAttribute1 not working!?

Posted on 2010-09-13
3
859 Views
Last Modified: 2013-12-24
Hey all!

I am creating accounts in AD which works perfectly. As soon as I try to add the extensionAttribute1 in the LDAP is fails:

if (!String.IsNullOrEmpty(extensionAttribute1))
                {                    
                    newUser.Properties["extensionAttribute1"].Add(extensionAttribute1);
                }

Any ideas?
0
Comment
Question by:KazooSoft
3 Comments
 
LVL 10

Expert Comment

by:james-ct16
ID: 33661760
Good evening

Couple of quick questions that may help you get an answer,

What is the error message you are getting?

What happens if you do a check first to see if extensionattribute1 exists eg newuser.Properties.contains ?

Regards

James
0
 
LVL 4

Author Comment

by:KazooSoft
ID: 33661833
There is no error being produced which is baffling me!

I have manually checked the LDAP and the field will not exist like many other fields I am setting but they all work :S

Cheers,
0
 
LVL 3

Accepted Solution

by:
aledev earned 500 total points
ID: 33663587
Hi
try this code and let me know
if (!String.IsNullOrEmpty(extensionAttribute1))
    if (user.Properties.Contains("extensionAttribute1"))
    {
        //update the attribute
        newUser.Properties["extensionAttribute1"].Value = extensionAttribute1;
    }
    else
    {
        //add it
        newUser.Properties["extensionAttribute1"].Add(extensionAttribute1);
    }
    newUser.CommitChanges();
}

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
dbcc checkdb datawarehouse 2 41
Syntax error 9 45
Anyway to make "All" the default in the dropdown? 6 34
WCF Service Application cannot connect from TCP terminal 1 13
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now