Helix Install Issue - Permissions on serialization folder - sitecore

Having a problem on a fresh Habitat setup... followed all steps, publish projects etc, but now I'm getting this error:
Access to the path '$(sourceFolder)\feature\accounts\serialization' is denied.
I've tried setting permissions on that folder, giving Everyone full access, but it doesn't make a difference.
Using latest version as of yesterday. Sitecore was working fine before publishing foundation projects. Have not yet run Unicorn Sync.
Any suggestions?
Here's the full error:
Access to the path '$(sourceFolder)\feature\accounts\serialization' is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessException: Access to the path '$(sourceFolder)\feature\accounts\serialization' is denied.
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET access to a file, right-click the file in File Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
Source Error:
Line 103: public Job StartRebuildAnalyticsIndexJob()
Line 104: {
Line 105: var options = new Sitecore.Jobs.JobOptions("Rebuild analytics index", "Indexing job", "shell", this, "RebuildAnalyticsIndex");
Line 106: return Sitecore.Jobs.JobManager.Start(options);
Line 107: }
Source File: C:\DATA\Latrobe.Sc\git\sitecore\src\foundation\Installer\code\MongoRestore\MongoRestoreService.cs Line: 105
Stack Trace:
[UnauthorizedAccessException: Access to the path '$(sourceFolder)\feature\accounts\serialization' is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +419
System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost) +1438
System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost) +73
Rainbow.Storage.SerializationFileSystemDataStore.InitializeRootPath(String rootPath) +313
Rainbow.Storage.SerializationFileSystemDataStore..ctor(String physicalRootPath, Boolean useDataCache, ITreeRootFactory rootFactory, ISerializationFormatter formatter) +233
lambda_method(Closure , Object[] ) +246
Unicorn.Configuration.MicroConfiguration.Activate(Type type, KeyValuePair`2[] unmappedConstructorParameters) +826
Unicorn.Configuration.<>c__DisplayClass7_0`1.<RegisterExpectedConfigType>b__2() +38
System.Lazy`1.CreateValue() +709
System.Lazy`1.LazyInitValue() +191
Unicorn.Data.ConfigurationDataStore.RegisterForChanges(Action`2 actionOnChange) +19
Unicorn.Data.DataProvider.UnicornDataProvider..ctor(ITargetDataStore targetDataStore, ISourceDataStore sourceDataStore, IPredicate predicate, IFieldFilter fieldFilter, IUnicornDataProviderLogger logger, IUnicornDataProviderConfiguration dataProviderConfiguration, ISyncConfiguration syncConfiguration, PredicateRootPathResolver rootPathResolver) +547
lambda_method(Closure , Object[] ) +391
Unicorn.Configuration.MicroConfiguration.Activate(Type type, KeyValuePair`2[] unmappedConstructorParameters) +826
Unicorn.Configuration.MicroConfiguration.Resolve() +118
System.Linq.WhereSelectArrayIterator`2.MoveNext() +102
System.Linq.Buffer`1..ctor(IEnumerable`1 source) +148
System.Linq.Enumerable.ToArray(IEnumerable`1 source) +106
Unicorn.Data.DataProvider.UnicornSqlServerDataProvider..ctor(String connectionString) +232
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +329
Sitecore.Reflection.ReflectionUtil.CreateObject(Type type, Object[] parameters) +119
Sitecore.Configuration.DefaultFactory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert) +119
Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +165
Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert) +72
Sitecore.Configuration.DefaultFactory.CreateObject(String configPath, String[] parameters, Boolean assert) +619
Sitecore.Configuration.DefaultFactory.CreateFromReference(XmlNode configNode, String[] parameters, Boolean assert) +170
Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +118
Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert) +72
Sitecore.Configuration.DefaultFactory.GetInnerObject(XmlNode paramNode, String[] parameters, Boolean assert) +932
Sitecore.Configuration.DefaultFactory.AssignProperties(XmlNode configNode, String[] parameters, Object obj, Boolean assert, Boolean deferred, IFactoryHelper helper) +560
Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +322
Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert) +72
Sitecore.Configuration.DefaultFactory.CreateObject(String configPath, String[] parameters, Boolean assert) +619
Sitecore.Configuration.DefaultFactory.GetDatabase(String name, Boolean assert) +157
Sitecore.Configuration.DefaultFactory.GetDatabase(String name) +55
Sitecore.Configuration.DefaultFactory.GetDatabases() +121
Sitecore.Data.Managers.LanguageProvider.InitializeEventHandlers() +73
Sitecore.Data.Managers.LanguageProvider..ctor() +225
Sitecore.DependencyInjection.DefaultSitecoreServicesConfigurator.<.cctor>b__a(IServiceProvider p) +31
Microsoft.Extensions.DependencyInjection.ScopedCallSite.Invoke(ServiceProvider provider) +117
Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite.Invoke(ServiceProvider provider) +117
Microsoft.Extensions.DependencyInjection.ScopedCallSite.Invoke(ServiceProvider provider) +117
Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) +100
Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider) +59
System.Lazy`1.CreateValue() +709
System.Lazy`1.LazyInitValue() +191
Sitecore.Globalization.Language.TryParse(String name, Language& result) +139
Sitecore.Globalization.Language.Parse(String name) +63
Sitecore.Jobs.JobOptions..ctor(String jobName, String category, String siteName, Object obj, String methodName, Object[] parameters) +593
Sitecore.Jobs.JobOptions..ctor(String jobName, String category, String siteName, Object obj, String methodName) +66
Sitecore.Foundation.Installer.MongoRestore.MongoRestoreService.StartRebuildAnalyticsIndexJob() in C:\DATA\Latrobe.Sc\git\sitecore\src\foundation\Installer\code\MongoRestore\MongoRestoreService.cs:105
Sitecore.Foundation.Installer.MongoRestore.MongoRestoreProcessor.Process(PipelineArgs args) in C:\DATA\Latrobe.Sc\git\sitecore\src\foundation\Installer\code\MongoRestore\MongoRestoreProcessor.cs:30
(Object , Object[] ) +170
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +484
Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
Sitecore.Nexus.Web.HttpModule.Application_Start() +259
Sitecore.Nexus.Web.HttpModule.Init(HttpApplication app) +704
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +618
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +402
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +343
[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +539
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +125
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +731

I had similar issue in my sitecore project.
And I was missing below configuration settings.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<sc.variable name="sourceFolder" value="C:\projects\Habitat\src" />
</sitecore>
</configuration>
Hope this helps you.
Thanks

Related

Server started to receive requests with invalid cookie _a_d3t6sf

Starting from 04.06.2018 our production site started to receive requests that contains the cookie with invalid value:
_a_d3t6sf="duUt#<WFf>>nD=9O&lG9y)DN"
values are different, but name is the same for all requests.
Exception looks like this:
System.Web.HttpRequestValidationException (0x80004005): A potentially dangerous Request.Cookies value was detected from the client (_a_d3t6sf="xdZ<et[)27rL^5lBe6rL_<[...").
at System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection)
at System.Web.HttpRequest.ValidateCookieCollection(HttpCookieCollection cc)
at System.Web.HttpRequest.get_Cookies()
at System.Web.HttpRequest.FillInParamsCollection()
at System.Web.HttpRequest.GetParams()
at System.Web.HttpRequest.get_Params()
at ASP._sites__shared_svc_getstrings_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in ___\getStrings.aspx:line 6
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP._sites__shared_svc_getstrings_aspx.ProcessRequest(HttpContext context) in ___\root\3403aaf9\baa39378\App_Web_zbqbtb3n.2.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
There is no such cookie in our code and there is no form posts or anything we can validate before that requests. We have validation mode 2.0 in our config
<httpRuntime targetFramework="4.5" requestValidationMode="2.0" />
so only .aspx pages throws that exception. One of them is callback page for a spanish online payment system. And it gets that cookie too from a real paysystem server - there was a payment done, request was sent to us, but was invalid because of that cookie.
There is a three .aspx pages that serves as minimization sources for styles, scripts and javascript localized strings. So one full page load throws three exceptions every time this happens, but only few clients has this cookie. On our computers we was unable to reproduce it.
So:
1. We has no things that adds or reads that cookie.
2. Not every client has it.
3. Secured request from online payment service sends payment data almots every day but also has that cookie once.
4. All windows updates including .net security was installed today - nothing has changed.
5. We can not turn validation off.
6. Last code changes was done month ago and all this started about two weeks ago.
Looking for any ideas and suggestions. Thank you.
Maybe you are using the zp.js or pluso-like.js plugins.
They do some suspisious activity and load 'processor.js' script that adds _a_d3t6sf cookie. If the client is lucky he will get safe cookie value like
duu2BAdLFlYTaTgr_h4WB6
but if he isn't he will get unsafe cookie value like
duu2BAdLFlYTaT#^0[AZ?WB6
There is some article about pluso.ru
My solution to this and all possible third-party invalid cookies:
1) Copy-paste or reflect CrossSiteScriptingValidation.cs class that is used to validate HttpRequest in framework internals:
https://referencesource.microsoft.com/#System.Web/CrossSiteScriptingValidation.cs,3c599cea73c5293b
2) In Global.asax on
protected void Application_BeginRequest( Object sender, EventArgs e ){}
validate cookies
// Validate and remove all invalid cookies
try
{
for( var i = Request.Cookies.Count - 1; i >= 0; i-- )
{
var cookie = Request.Cookies.Get( i );
if( string.IsNullOrWhiteSpace( cookie?.Value ) )
{
continue;
}
if( CrossSiteScriptingValidation.IsDangerousString( cookie.Value ) )
{
Request.Cookies.Remove( cookie.Name );
// Remove cookie from client
Response.Cookies.Add( new HttpCookie( cookie.Name ) { Expires = DateTime.Now.AddDays( -1d ) } );
}
}
}
catch( Exception ex )
{
Log.Error( "Failed to validate cookies. ", ex );
}

Fail to deploy to Azure a simple django webapp that works well on local machine

I have a simple Django webapp that works like a charm on my machine. However, when I tried to publish it to Azure Webapp using VS 2015 (by right click the project then click Publish button), it turns out a run time error:
Then I tried to fix by add "< customErrors mode="Off"/>" to the web.config file. It turns out another error:
Server Error in '/' Application.
Couldn't find type for class
Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener,
Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, ..
I tried the this and this tutorial but they do not help. I do not know whether these documents are out of date of not.
Please save my day.
Update:
I am not sure which log file to post as I am new to Azure. Here is what in file eventlog.xml:
<Data>D:\home\site\wwwroot\</Data>
<Data>RD0003FF2899E0</Data>
<Data/>
<Data>9328</Data>
<Data>w3wp.exe</Data>
<Data>IIS APPPOOL\DjangoWebProject220170522042402</Data>
<Data>TargetInvocationException</Data>
<Data>Exception has been thrown by the target of an invocation.
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Web.Compilation.BuildManager.RestorePortableCompilationOutputSnapshot()
at System.Web.Compilation.BuildManager.ExecutePreAppStart()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
Couldn't find type for class Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
at System.Diagnostics.TraceUtils.GetRuntimeObject(String className, Type baseType, String initializeData)
at System.Diagnostics.TypedElement.BaseGetRuntimeObject()
at System.Diagnostics.ListenerElement.GetRuntimeObject()
at System.Diagnostics.ListenerElementsCollection.GetRuntimeObject()
at System.Diagnostics.TraceInternal.get_Listeners()
at System.Diagnostics.TraceInternal.WriteLine(String message)
at Microsoft.Web.Compilation.Snapshots.SnapshotHelper.RestoreSnapshot(String options)
</Data>
<Data>http://djangowebproject220170522042402.azurewebsites.net/handler.fcgi/</Data>
<Data>/handler.fcgi/</Data>
<Data>62.177.198.5</Data>
<Data/>
<Data>False</Data>
<Data/>
<Data>IIS APPPOOL\DjangoWebProject220170522042402</Data>
<Data>21</Data>
<Data>IIS APPPOOL\DjangoWebProject220170522042402</Data>
<Data>False</Data>
<Data> at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Web.Compilation.BuildManager.RestorePortableCompilationOutputSnapshot()
at System.Web.Compilation.BuildManager.ExecutePreAppStart()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
</Data>
And DetailErrors files:
<fieldset><h4>Most likely causes:</h4>
<ul> <li>IIS received the request; however, an internal error occurred during the processing of the request.
The root cause of this error depends on which module handles the request and
what was happening in the worker process when this error occurred.</li>
<li>IIS was not able to access the web.config file for the Web site or
application.
This can occur if the NTFS permissions are set incorrectly.</li> <li>IIS
was not able to process configuration for the Web site or application.</li>
<li>The authenticated user does not have permission to use this DLL.</li>
<li>The request is mapped to a managed handler but the .NET Extensibility
Feature is not installed.</li> </ul>
</fieldset>
</div>
<div class="content-container">
<fieldset><h4>Things you can try:</h4>
<ul> <li>Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server's machine account.</li> <li>Check the event logs to see if any additional information was logged.</li> <li>Verify the permissions for the DLL.</li> <li>Install the .NET Extensibility feature if the request is mapped to a managed handler.</li> <li>Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click here. </li> </ul>
</fieldset>
</div>
I tried solution from this threads and it worked:
Disable the Dynamic Cache by going to the Azure Portal -> Application
Settings and then setting the value of 'WEBSITE_DYNAMIC_CACHE' to '0'
(zero).

Windows Identity Foundation exception with WSO2 Identity Server 5.0

Windows Identity Foundation has trouble accepting SAML2 tokens requested from WSO2’s WS-Trust (see exception). Is it possible to change the token or is there a known solution to this problem?
System.Xml.XmlException: Cannot read KeyIdentifierClause from element 'Reference' with namespace 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'. Custom KeyIdentifierClauses require custom SecurityTokenSerializers, please refer to the SDK for examples.
at System.IdentityModel.Tokens.WSSecurityJan2004.SecurityTokenReferenceJan2004ClauseEntry.ReadKeyIdentifierClauseCore(XmlDictionaryReader reader)
at System.IdentityModel.Tokens.KeyInfoSerializer.ReadKeyIdentifierClauseCore(XmlReader reader)
at System.IdentityModel.Tokens.SecurityTokenHandlerCollection.ReadKeyIdentifierClauseCore(XmlReader reader)
at System.IdentityModel.Protocols.WSTrust.WSTrustSerializationHelper.ReadRSTRXml(XmlReader reader, RequestSecurityTokenResponse rstr, WSTrustSerializationContext context, WSTrustConstantsAdapter trustConstants)
at System.IdentityModel.Protocols.WSTrust.WSTrust13ResponseSerializer.ReadXml(XmlReader reader, WSTrustSerializationContext context)
at System.IdentityModel.Services.WSFederationSerializer.CreateResponse(FederationMessage message, WSTrustSerializationContext context)
at System.IdentityModel.Services.WSFederationAuthenticationModule.GetXmlTokenFromMessage(SignInResponseMessage message, WSFederationSerializer federationSerializer)
at System.IdentityModel.Services.WSFederationAuthenticationModule.GetSecurityToken(SignInResponseMessage message)
at System.IdentityModel.Services.WSFederationAuthenticationModule.SignInWithResponseMessage(HttpRequestBase request)
at System.IdentityModel.Services.WSFederationAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs args)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Google Admin SDK Unable to Create User - Exception 403 Forbidden

I am trying to create a user using C# and the google-admin-directory_v1-rev24-csharp-1.7.0-beta client libraries however I keep geting an exception:
Google.GoogleApiException was unhandled
HResult=-2146233088
Message=Google.Apis.Requests.RequestError
Not Authorized to access this resource/api [403]
Errors [
Message[Not Authorized to access this resource/api] Location[ - ] Reason[forbidden] Domain[global]
]
Source=Google.Apis
ServiceName=admin
StackTrace:
at Google.Apis.Requests.ClientServiceRequest`1.Execute() in c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug \output\default\Src\GoogleApis\Apis\Requests\ClientServiceRequest.cs:line 102
at ConsoleApplication1.Program.Main(String[] args) in c:\Users\darin.BASEHEX\Documents\Visual Studio 2013\Projects \ConsoleApplication1\ConsoleApplication1\Program.cs:line 55
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
I started by creating a project in the Developers console, under the APIs settings page I turned on the ADMIN SDK, under the Credentials page I created a Service Account and downloaded the p12.key certificate, I filled out the Consent Screen and then I went to the Security page on the Admin Console, selected the Advance tab, selected the Manage third party OAuth Client access, pasted in the Client ID from the Service Account I created and assigned the scope https://www.googleapis.com/auth/admin.directory.user/. The exception is being raised on the line:
User results = service.Users.Insert(newuserbody).Execute();
The complete C# program is below.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography.X509Certificates;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Admin.Directory.directory_v1;
using Google.Apis.Admin.Directory.directory_v1.Data;
using Google.Apis.Services;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
String serviceAccountEmail = "A bunch of alpha numerics#developer.gserviceaccount.com";
var certificate = new X509Certificate2(#"key.p12", "notasecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { DirectoryService.Scope.AdminDirectoryUser },
User = "admin#mydomain.com" <-------- Added ADMIN User to fix
}.FromCertificate(certificate));
// Create the service.
var service = new DirectoryService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "User Provisioning",
});
User newuserbody = new User();
UserName newusername = new UserName();
newuserbody.PrimaryEmail = "bbacon#mydomain.com";
newusername.GivenName = "Bob";
newusername.FamilyName = "Bacon";
newuserbody.Name = newusername;
newuserbody.Password = "iambacon";
User results = service.Users.Insert(newuserbody).Execute();
Console.WriteLine("Press any key to continue!");
Console.ReadKey();
}
}
}
I feel like it is something really simple I am missing however I have run out of any ideas on what to look at. Any help would be greatly appreciated!
It doesn't look like that your service account is impersonating any users in this call. When you want to use a service account to create a new user, you need to impersonate as the administrator account (Note: only administrator can create users).
Take a look at this Drive example for domain wide delegation:
https://developers.google.com/drive/delegation
You can see that for the .net portion, it has this extra line:
ServiceAccountUser = userEmail
You need to create a service object authorized with the service account that will acts on behalf of the given user.

How can use topologymanager obsolete Namespace in Custom SharePoint Web Service?

I am unable to Use the Topologymanager class inside the namespace Microsoft.SharePoint.Portal.Topology. I searched a lot. Its urgent. Thanks
I am getting the following error. When I include the namespace "Microsoft.SharePoint.Portal.Topology" in my Custom Web service.
A runtime exception was detected.
Details follow. Message: Cannot open
database "WSS_Content_Dev3" requested
by the login. The login failed. Login
failed for user
Techinal Details:
System.Data.SqlClient.SqlException:
Cannot open database
"WSS_Content_Dev3" requested by the
login. The login failed. Login failed
for user .
at
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj) at
System.Data.SqlClient.TdsParser.Run(RunBehavior
runBehavior, SqlCommand cmdHandler,
SqlDataReader dataStream,
BulkCopySimpleResultSet
bulkCopyHandler, TdsParserStateObject
stateObj) at
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean
enlistOK) at
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
serverInfo, String newPassword,
Boolean ignoreSniOpenTimeout, Int64
timerExpire, SqlConnection
owningObject) at
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String
host, String newPassword, Boolean
redirectedUserInstance, SqlConnection
owningObject, SqlConnectionString
connectionOptions, Int64 timerStart)
at
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
owningObject, SqlConnectionString
connectionOptions, String newPassword,
Boolean redirectedUserInstance) at
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString
connectionOptions, Object
providerInfo, String newPassword,
SqlConnection owningObject, Boolean
redirectedUserInstance) at
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection
owningConnection) at
System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection
owningConnection,
DbConnectionPoolGroup poolGroup) at
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection) at
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory
connectionFactory) at
System.Data.SqlClient.SqlConnection.Open()
at
Microsoft.Office.Server.Data.SqlSession.OpenConnection()
at
Microsoft.Office.Server.Data.SqlSession.ExecuteNonQuery(SqlCommand
command) at
Microsoft.Office.Server.Data.SqlDatabaseManager.HasAccess(String
user) at
Microsoft.Office.Server.Administration.SharedResourceProvider.SynchronizeAccessControl(SharedComponentSecurity
sharedApplicationSecurity) at
Microsoft.Office.Server.Administration.SharedResourceProvider.Microsoft.Office.Server.Administration.ISharedComponent.Synchronize()
Finally got the solution:
When you Use the templogymanager inside the web service directly or even include the namespace "Microsoft.SharePoint.Portal.Topology" at the top of the custom web service. It gives you error. I did the following thing.
I create the helper project in which I used the namespace Microsoft.SharePoint.Portal.Toplogy.
Compile it and put the dll into GAC.
Add the .dll reference to my project.
Then I called the helper Method in my custom web service.
Problem Solve.